Dynamic Table row bgcolors?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

Dynamic Table row bgcolors?

Post by jonas »

How would you make say the following code have different row bgcolors?

Like the first row displayed would be white, the second would be grey and the third would be back to white...

Let's use this code as an example:

Code: Select all

$query = "SELECT * FROM systems";
	$mysql_stuff = mysql_query($query, $mysql_link);
	while($roc = mysql_fetch_row($mysql_stuff)){
		$systemID = $rocї0];
		$system_name = $rocї1];
		print("<tr><td><div align="center"><a href="editagame-sys.php?systemID=$systemID" target="main">$system_name</a></div></td></tr>");
	&#125;
So I want the first output to have a lets say white bgcolor and the second to be grey bgcolor and the third would be back to white.

What's the best way to achieve this?
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

jonas
Forum Commoner
Posts: 96
Joined: Sun May 23, 2004 9:25 pm

Post by jonas »

Yes! Not only have you given me my answer, but you are a robot monkey!
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

a magical robot monkey! wooo ooo ooooo!
Post Reply