Forum Moderators: coopster
<?php
$res=mysql_query("SELECT * FROM comment ORDER BY id ASC");
while($remark = mysql_fetch_array($res))
{
$c_id=$remark["id"];
if($c_id%2)
{
echo "<div class='grey'>";
}
else
{
echo "<div class='white'>";
}
?> function oddEven($num)
{
return ($num%2) ? TRUE : FALSE;
}
$rowCount = 0;
// execute your query here
while ($row3 = mysql_fetch_array($result3))
{
$rowCount++;
if (oddEven($rowCount) === TRUE){ echo '<div class='grey'>"';} else {echo "<div class='white'>";}
echo 'more data here';
echo '</div>'; // this is to close the grey/white div
}
$res=mysql_query("SELECT * FROM comment ORDER BY id ASC");
while($remark = mysql_fetch_array($res)){
$bg = ($bg==$gray)?$white:$gray;
echo "<div class=\$bg\">";
}
and also in---if (oddEven($rowCount) === TRUE) there are 3equal operators are used.is it a typo? coz 2equals are also working fine.
http://gr.php.net/manual/en/language.operators.comparison.php