Zebra Tables

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
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Zebra Tables

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
Last edited by feyd on Mon Sep 27, 2004 8:25 pm, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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?
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post 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.
Post Reply