A (Hopefully) simple question *gulp*

From: Date: Fri, 28 Apr 2000 02:13:40 +0000
Subject: A (Hopefully) simple question *gulp*
Groups: php.version4 
Request: Send a blank email to php-version4+get-14121@lists.php.net to get a copy of this message
Hi guys, I sent this bit of code here a while back and everyone was REALLY helpful. I'm hoping to get the same sort of results this time (fingers crossed). I use this snippet to display the rows of a user-configured select in a table format. " elseif ($disp) { if ($subcats == "All") { $result = mysql_query("SELECT $sources FROM $catty",$db); } else { $result = mysql_query("SELECT $sources FROM $catty WHERE SubCategory = '$subcats' order by $sorter",$db); } echo ">> $subcats $catty Query sorted by $sorter<br>"; echo "<table cellspacing=\"2\" class=\"narea\">"; echo "<tr>\n"; echo "<td valign=\"center\">ID</td><td align=\"center\" valign=\"center\">Dept</td><td>Category</td><td>Sub-Category</td><td>Description</td><td>Make</td><td>Model</td><td>Model Number</td><td>Serial Number</td><td>Date Acq'd</td><td>Vendor</td>\n"; echo "</tr>\n"; while ($row = mysql_fetch_row($result)){ echo "<tr bgcolor=\"#00AAAA\">"; // The next bit turns the id number into a link to edit the properties // // of the line item. It uses the javascript from way back in the beginning // // of the script to popup a little editing window // for ($p = 0;$p < count($row);$p++) { if ($p == 0) { echo "<td><font size=\"2\" face=\"arial, helvetica\">"; echo "<a href='javascript:openPopWin(\".//update/update.php?id=$row[$p]&catty=$catty\", 400, 400, \"\", 1, 1)'>$row[$p]</a>"; } else { echo "<td><font size=\"2\" face=\"arial, helvetica\"> $row[$p]</font></td>"; } } echo "</tr>"; } " and it works BRILLIANTLY. Here comes the question. I've seen a lot of tables built in php with alternating row colors. Most notably phpmyadmin and freshmeat.net. What I mean is, the first row is a certain color, then the second row is a second color, the third row goes back to the original color...and so on and so forth. Is there a relatively simple way to do this? If I have to, I suppose I could try and dismantle the phpmyadmin code (wouldn't be the first time.. =) but I'd rather not as there are a lot of things there that I don't need. Ideas anyone? TIA, Bradley

« previous php.version4 (#14121) next »