Jump to content

Recommended Posts

We  want to access  mysql table ad have  row  colors alternate, rows 1,3,5...=white and rows

2,4,6,8..=red.  if we have  a running row counter[$ROWCOUNT] Then we tried:

 

if ($ROWCOUNT %2 ==0){color=red;}else {color=white:}

$ROWCOUNT=$ROWCOUBNT + 1;

but all rows are white

 

Thanks,

 

Jennifer

Link to comment
https://forums.phpfreaks.com/topic/60270-php-arithmetic/
Share on other sites

Here is what I usually do...

 

$rownum = 0;
while($row = $db->fetch($result)){
//DB stuff here

$tr = $rownum % 2;

echo "<tr class=\"tr".$tr."\">";

//out put information

echo "</tr>";

$x++;

}

 

in the css

.tr0{
background-color:red;
}

.tr1{
background-color:white;
}

 

...something like that, hope it helps

Link to comment
https://forums.phpfreaks.com/topic/60270-php-arithmetic/#findComment-299779
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.