PHP Scripts
Alternate coloured rows in a table
This
example reads a database, and displays results.
The example creates a table
(you can view and format the table in standard html) and then pastes information,
swapping row colours if the row result is divisible by 2..
<TABLE
WIDTH="100%" HEIGHT="40" BORDER="0" CELLPADDING="10"
CELLSPACING="5" BGCOLOR="#FFFFFF"> // General display the table information and titles of the columns <TD
HEIGHT="40" ALIGN=bottom ID="header"><em><FONT
FACE="Verdana, Arial, Helvetica, sans-serif" SIZE="1" COLOR="#8A8A8A">Column
A </FONT></em></TD> //an
empty spacer row $num=mysql_num_rows($result); //
Count rows in database and assign variables to results while
($i < $num) { // alternate #8F8F8F with #000000 print ($i % 2) ? "<tr bgcolor=\"8F8F8F\">" : "<tr bgcolor=\"000000\">"; print
"<td align=right>$a</td>"; |