Jump to content

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";
}
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.