0

Okay,

I have a posting system, so when a user posts something it displays..

Now I want the background of these to be like this:

  • White
  • Grey
  • White
  • Grey

Now, I've done it before, but only using tables.. So I'd have like:

<?php

  $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
  echo '<tr bgcolor="' .$bg. '">';
?>

But how would I do it for divs?

Thanks :)

Edited by mike_2000_17: Fixed formatting

3
Contributors
3
Replies
6
Views
6 Years
Discussion Span
Last Post by karthik_ppts
0

Although I think this thread should be put in the HTML and CSS forum (in the Web Design section), I'll answer:
Instead of writing bgcolor="'.$bg.'" you can type:

<div style="background-color:'.$bg.'"></div>

Edited by Pro2000: n/a

0

Try this with your code

$i=0;
while($item=mysql_fetch_array($rs))
{
if($i%2==0)
{
    $bgcolor='#eeeeee';
}
else
{
    $bgcolor='#ffffff';
}
$i++;

echo "<div bgcolor='$bgcolor'>".$item['post']."</div>";
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.