[PHP-DB] SELECT html table

2005-12-04 Thread Ron Piggott (PHP)
I have two questions.  

I would like to display the contents of my table with the first row
being grey in background and the next row being white and the third row
being grey, fourth being white, etc.  I am not sure how to do this.

Secondly I only want the first 20 records to be displayed at a time and
then I want to create a NEXT link for the next 20 records (21-40) ...
any idea how you would use the SELECT command to do this?

Ron

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] SELECT html table

2005-12-04 Thread Robbert van Andel
There's a couple of ways to do this.  For the row color you would set that
as you looped through the returned rows.  Using the pear db class:

$count = 0;
echo table\n;
while($db-fetchInto($data)) {
$count++;
if($count % 2 == 0) {
$bgColor = background-color:#dcdcdc;
}
else {
$bgColor = background-color:transparent;
}
echo tr style='$dgColor'\n;
foreach($data as value) {
echo td . htmlentities($value) . /td\n;
}
echo /tr\n;
}

As for the limiting of rows, you would use the limit statement (assuming
you're using a DBMS that supports it).

Hopefully this helps,
Robbert van Andel

-Original Message-
From: Ron Piggott (PHP) [mailto:[EMAIL PROTECTED] 
Sent: Sunday, December 04, 2005 10:39 AM
To: PHP DB
Subject: [PHP-DB] SELECT  html table

I have two questions.  

I would like to display the contents of my table with the first row
being grey in background and the next row being white and the third row
being grey, fourth being white, etc.  I am not sure how to do this.

Secondly I only want the first 20 records to be displayed at a time and
then I want to create a NEXT link for the next 20 records (21-40) ...
any idea how you would use the SELECT command to do this?

Ron

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: SELECT html table

2005-12-04 Thread JeRRy
  From:  Ron Piggott (PHP) [EMAIL PROTECTED]To:  PHP DB 
php-db@lists.php.netDate:  Sun, 04 Dec 2005 13:38:58 -0500Subject:  
SELECT  html table 


I have two questions.  I would like to display the contents of my table 
with the first row  being grey in background and the next row being white and 
the third row  being grey, fourth being white, etc.  I am not sure how to do 
this.Secondly I only want the first 20 records to be displayed at a time 
and  then I want to create a NEXT link for the next 20 records (21-40) ...  
any idea how you would use the SELECT command to do this?Ron  
 [input]   [input]   [input]   [input]   [input]   [input]   [input]   
[input]  
   
   
  Visit http://www.mysql.com/ and read a little bit about LIMIT command. :)
   
  Jerry


-
Do you Yahoo!?
  Take your Mail with you - get Yahoo! Mail on your mobile 

-
Do you Yahoo!?
  Never miss an Instant Message - Yahoo! Messenger for SMS

[Fwd: Re: [PHP-DB] Re: SELECT html table]

2005-12-04 Thread Shahmat Dahlan


--
Best Regards,

Shahmat Dahlan
Research and Development
SAINS

Mobile: +(60)16 882 6130
Office: +(60)82 426 733 ext 5512

---BeginMessage---

(1)
i've been using this method for years now, maybe somebody else has a 
better way to do this?

?
sql query
$i = 0;
while (sql result fetches) {
if ($i%2 =! 0) { $bg = 'background=white'; }
else { $bg = ''; }
  echo tr $bg;
  php codes
  $i++;
}
?

(2) check out the limit syntax in the mysql manuals.
select * from table limit startindex, number of rows
you should work out on how to use the concept of pages, and how many 
rows in a page, in which you had mentioned 20.
count the number of page base on the number of records returned then you 
get the total number of pages for particular returned result
i'm thinking of the function ceil, at least i think it's the ceiling 
function.


e.g.
if pg = 1
maxrows=20
start = ($pg-1)*$maxrows
select * from table $start, $maxrows



pls feel free to correct me


JeRRy wrote:

 From:  Ron Piggott (PHP) [EMAIL PROTECTED]To:  PHP DB php-db@lists.php.netDate:  Sun, 04 Dec 2005 13:38:58 -0500Subject:  SELECT  html table 



I have two questions.  I would like to display the contents of my table with the first row  being grey in background and the next row being white and the third row  being grey, fourth being white, etc.  I am not sure how to do this.Secondly I only want the first 20 records to be displayed at a time and  then I want to create a NEXT link for the next 20 records (21-40) ...  any idea how you would use the SELECT command to do this?Ron  
[input]   [input]   [input]   [input]   [input]   [input]   [input]   [input]  
  
  
 Visit http://www.mysql.com/ and read a little bit about LIMIT command. :)
  
 Jerry



-
Do you Yahoo!?
 Take your Mail with you - get Yahoo! Mail on your mobile 
		

-
Do you Yahoo!?
 Never miss an Instant Message - Yahoo! Messenger for SMS
 




--
Best Regards,

Shahmat Dahlan
Research and Development
SAINS

Mobile: +(60)16 882 6130
Office: +(60)82 426 733 ext 5512



---End Message---
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php