Forum Moderators: coopster
I have a problem because the background-color is always the same while I expect it to change for the next retrieved row.
If you use phpMyAdmin(which you do)you have seen that row color is repeated for every next row in an alternative way.
Can you spot the error i made that keeps me from getting the intended result?
Here's the code:
<?php
$i = 0;
while($row = mysql_fetch_assoc($result)) {?>
<?php
$i++;
if($i%2)
{
$bg_color = "#EEEEEE";
}
else {
$bg_color = "#E0E0E0";
}
?>
<tr bgcolor="$bg_color">
<td width="10%" style="border:0;"><?php echo $row["name"];?></td>
<td width="10%" style="text-align:right; border:0;"><?php echo $row["title"];?></td>
<td width="60%" style="text-align:right; padding-left:5;"><?php
$extract = substr($row["content"], 0, 100);
$lastSpace = strrpos($extract, " ");
if(strlen($row["content"]) <= 101) {
echo $row["content"];
}
else {
echo substr($row['content'], 0, $lastSpace)."... <a href='article.php?article_id=". $row['article_id']."'>
Read More </a>";
}
?>
</td>
<td width="10%" style="border:0; text-align:right;"><a href="update_article.php?article_id=<?php echo $row["article_id"];?>">EDIT</a> </td>
<td width="10%" style="border:0; text-align:right;"><a href="delete_article.php?article_id=<?php echo $row["article_id"];?>">DELETE</a></td>
</tr> <?php }
?>
Regards,
dbarasuk