Jump to content


Photo

mysql queries


  • Please log in to reply
2 replies to this topic

#1 chriscloyd

chriscloyd
  • Members
  • PipPipPip
  • Advanced Member
  • 489 posts
  • LocationArizona

Posted 31 May 2006 - 05:41 AM

how could i make it alternate rows like this when it quires a table

[a href=\"http://www.chris.ac/test.html\" target=\"_blank\"]http://www.chris.ac/test.html[/a]
44 bugs in my java code
44 bugs in my java code
Fix 1 bug, and complie again
122 bugs in my java code

#2 Abbner

Abbner
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 31 May 2006 - 05:54 AM

i dont claim this is the best solution, but the way i have always done it is along the lines of keeping a variable that goes back and forth between 1 and 0. when its 1, have the color of the background be something, and when its 0, have it be something else. when you are printing out all the rows just put in a line of code like $rowcolor = 1 - $rowcolor; this should alternate it back and forth between 1 and 0.

#3 samshel

samshel
  • Members
  • PipPipPip
  • Advanced Member
  • 837 posts

Posted 31 May 2006 - 06:22 AM

<?php 

for($i=0;$i<10;$i++) {//for loop which displays rows
    if(($i % 2) != 0) {
       $bgcolor = "#000000";
    } else {
       $bgcolor = "#333333";
    }
    echo "<tr><td bgcolor=\"$bgcolor\"><div align=\"center\" class=\"style1\">user</div></td></tr>";
}

?>

hth
Cheers,
SamShel
-----------------------------------------------
--: FUTURE IS LINUX :--
-----------------------------------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users