RE: [PHP] Returning table rows from MySQL
| From: | Ford, Mike [LSS] | Date: | Mon, 18 Feb 2002 18:34:09 +0000 |
| Subject: | RE: [PHP] Returning table rows from MySQL | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-85244@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Scott Saraniero [mailto:Scottsar@aminternet.com]
> Sent: 18 February 2002 18:02
> To: php-general@lists.php.net
>
> 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?
Easy one: see additional/changed lines below:
>
> <?php
>
> $Host = "";
> $User = "";
> $Password = "";
> $DBName = "";
> $TableName = "";
>
> $Link = mysql_connect($Host, $User, $Password);
>
> $Query = "SELECT * FROM $TableName";
>
> $Result = mysql_db_query($DBName, $Query, $Link);
>
>
>
> print ("<table border=1 width=\"65%\" cellpadding=3 align=center>");
> print ("<tr>");
> print ("<th class=\"textOnWhite\">Song</th>");
> print ("<th class=\"textOnWhite\">Artist</th>");
print "</tr>"; // ** missing in your original!! **
$alt_color = TRUE;
>
> while ($Row =mysql_fetch_array($Result)) {
> print ("<tr>");
$class = $alt_color ? 'textOnColor' : 'textOnWhite';
> print ("<td class=\"$class\">$Row[song]</td>");
> print ("<td class=\"$class\">$Row[artist1]
> $Row[artist]</td>");
>
>
$alt_color = !$alt_color;
>
> }
> print "</table>";
>
>
>
>
> mysql_close($Link);
>
> ?>
>
> Thanks,
> Scott
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>