|
|
|
|
|
|
|
Hello there This is one way someone can alternate table row colors. Makes the information much easier to scan/read. There may be a few typo's but the code should work properly:D By : shaker <html> <head> <title>Alternating Row Colors</title> </head> <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0"> <table width="300" height="400"> <? // Connect to MySQL mysql_connect ('localhost', 'username', 'password') or die ("Can't connet to MySQL server."); mysql_select_db ('dbname'); $result = mysql_query (SELECT * FROM table); if ($row = mysql_fetch_array($result)) { for ($i = 0; i < count($row); $i++) { // Set Table Row Color if ($i % 2) { echo "<tr bgcolor=B0C4DE>"; } else { echo "<tr bgcolor=FOF8FF>"; } // Now display our table cell info ?> <td><? echo $row["whatever"]; ?></td> </tr> <? } else { echo "<tr bgcolor=B0C4DE><td>Sorry, no records were found!</td></tr>"; } ?> </table> </body> </html>
More GUI Code Articles |
| |
| |