Jump to content


Photo

Alternating table colours


  • Please log in to reply
3 replies to this topic

#1 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 28 March 2006 - 11:22 AM

I have a simple "while" loop that creates a table. but for appearance, i would like it to alternate in colours, as in 2 types of gray background or something.
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 28 March 2006 - 11:29 AM

Check for odd/even row numbers

$count = 0;

while (.....) {


          $bg = ($count++ % 2) ? '#EEEEEE' : '#CCCCCC';

          echo "<TR style='background-color: $bg'>\n";

                # cell data here

          echo "</TR>\n";
}

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 28 March 2006 - 11:29 AM

Might look here...

[a href=\"http://www.phpfreaks.com/tutorials/5/0.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/5/0.php[/a]

Lite..

oops! too slow again.

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#4 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 28 March 2006 - 11:39 AM

thanks! for the help, as im doing this whole project and have no time to test, i will let you know if it went well! thanks
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users