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 :)

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>

Post your code from while($item=mysql_fetch_array($rs))

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>";
}