Page 1 of 1

Zebra Tables

Posted: Mon Sep 27, 2004 8:07 pm
by C_Calav
hi guys,

ive recently stumbled on the zebra table's. i can make and use them in html, but i cant seem to get my head around how to do it in php.

i found this article on alistapart.com http://www.alistapart.com/discuss/zebratables/6

does anyone use them or know anything about how to write them in php?

thanx very much

Posted: Mon Sep 27, 2004 8:21 pm
by feyd
there's an example of a php version on that page..

the basics are: you have x number of classes for the row coloration. You use the modulo operator (%) to determine which row coloration you should use with the current row of output. It's quite simple actually.

I'm absolutely sure we've talked about them before, I just can't remember what text there was for me to search for it :D

edit: here's one
viewtopic.php?t=13897&highlight=color+c ... w+alter%2A

Posted: Mon Sep 27, 2004 8:22 pm
by Christopher
There are several ways to do them. They all use similar logic of looping and alternating. Are you embedding PHP in HTML or are you using a template system?

Posted: Mon Sep 27, 2004 8:27 pm
by C_Calav
umm.. yeah embeding the php in the html.. ok so i guess will go with the code on alistapart!

just checking to see what you guys think.