Jump to content

Alternating Table Backgrounds...?


unsider

Recommended Posts

I'm not sure exactly what it is called, but here is an example of it..

http://ronpaulmarch.com/

scroll half way down and there is a list of 20 cities, with an alternating grey and white background.

 

I'm curious how that is done, with both CSS or PHP, or both.

I already have tables set up for comments on my own project and I'm looking alternate the background colors, for more appeal to the section.

 

Thanks. Sorry if the question is inadequate. Wasn't sure how to ask :)

Link to comment
https://forums.phpfreaks.com/topic/86808-alternating-table-backgrounds/
Share on other sites

Make a variable for the table row background colour and every time your mysql database spits out another row, you set the colour to something else, for example...

 

$colour = "dodgerblue"; //Sorry, too lazy to find the hex code...
while($row = mysql_fetch_array($rs)){
echo "<tr><td bgcolor='$colour'>$row</td.</tr>";
if($colour == "dodgerblue"){
$colour = "skyblue"; //Don't know if that's a real colour xD
}else{
$colour = "dodgerblue";
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.