|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I posted this question in the XML forum about a week ago, but for some reason or another haven't recieved any answer... and I know it's probably just a simple solution I've overlooked.
I need to be able to dynamically change the color of every other row in a table. I've tried 4 different methods and none of them seem to work. Any help is greatly appreciated. |
|
#2
|
|||
|
|||
|
I just did this with a PHP table created from database input.
PHP Code: <? $dbLink = mysql_connect("localhost", "sample", ""); mysql_select_db("sample", $dbLink); $Query = "SELECT ID, DESCRIPTION, CATEGORY, PRICE " . "FROM Feeders "; $dbResult = mysql_query($Query, $dbLink); $color1 = "#CCCCCC"; $color2 = "#FFFFFF"; $color = $color1; print("<table border='0' cellspacing='5' cellpadding='0'>"); print("<form>"); print("<tr><td><b>Quantity</b></td><td><b>ID</b></td><td><b>Description</b></td><td><b>Cat egory</b></td><td><b>Price</b></td></tr>"); while($row = mysql_fetch_array($dbResult, MYSQL_ASSOC)) { print("<tr bgcolor=".$color."><td align='center'><input type='text' size='2' name='$row[DESCRIPTION]'></td>" . "<td>" . $row[ID] . "</td>" . "<td>" . $row[DESCRIPTION] . "</td>" . "<td>" . $row[CATEGORY] . "</td>" . "<td>$" . $row[PRICE] . "</td></tr>n"); if ($color == $color1) { $color = $color2; } else { $color = $color1; } } print("</form>"); print("</table>"); ?> This should work similarly in other langauges. Hope this helps. |
|
#3
|
|||
|
|||
|
Thanks for your input.
![]() XML/XSL is strange though, so I finally got and used a different method. Anyone interested can find it in the XML forum. |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > alternating row colors |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|