Re: Returning table rows from MySQL
| From: | Matt Drake | Date: | Mon, 18 Feb 2002 18:57:18 +0000 |
| Subject: | Re: Returning table rows from MySQL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-85248@lists.php.net to get a copy of this message | ||
On Mon, 18 Feb 2002, Scott Saraniero wrote:
> I've got a piece of code below that works great for me. Now I would like to
> modify the rows with alternating colors in the displayed results. Any
> suggestions on how to do this?
Try this:
$Count = 0;
while ($Row = mysql_fetch_array($Result) {
print("<tr>");
print('<td ');
if($Count % 2)
print ('class="textOnWhite")';
else
print ('class="textOnGray")';
print('>');
...
$Count++;
}
You could probably replace $Count with some mysql function (it would be named something like
mysql_current_row($Result)), but I obviously don't know that much about it.
Matt