Page 1 of 1
making every other line a different colour
Posted: Wed Jun 06, 2007 11:28 am
by aceconcepts
hi,
If i extract a list of data from a database how can I make every other row a different colour.
Here is an example of how I'd like it to look:
http://unstats.un.org/unsd/methods/m49/ ... a.htm#ftna
Thanks
Posted: Wed Jun 06, 2007 11:42 am
by blackbeard
After you extract the data, use a for loop to echo out each row. Inside the loop, test for odd/even, and set the background color for the row as needed.
Posted: Wed Jun 06, 2007 11:43 am
by guitarlvr
In your CSS sheet you could have two different ID's for the different background color rows. When you are looping through your results, alternate the tags when filling in the table.
Wayne
Posted: Wed Jun 06, 2007 1:05 pm
by RobertGonzalez
What you are looking for is commonly refered to as zebra striping or alternating row colors. There have been thousands of posts (maybe hundreds, but I think thousands sums it up best) about this topic in this community. Search around a little. You'll find them.