Hey people,
I'm can't get an IF statement to do what I want. It's a simple FOR loop which pulls data from a database and puts it into a table. The IF statement is basically putting the <tr></tr> at the end of every 10 rows. I can't get it to put only an </tr> at the end of the loop.
Here's my code:
$x = 0;
$y = 0;
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
$background = $row[color];
$id = $row[id];
$taken = $row[taken];
echo "<td class=\"cell\"><a class=\"test\" ";
if ( $taken == '0' ){
echo "style=\"background:#".$background."\" href=\"http://www.mysite.com/1.php?cell=".$id."\"></a></td>\n";
}
else {
echo "style=\"background:#".$background."\" href=\"http://www.mysite.com/1.php?cell=".$id."\"></a></td>\n";
}
$x++;
if( $x == 10 && $y < 10)
{
echo "
</tr>
<tr>\n";
}
elseif ( $x < 10 && $y < 10)
{
}
elseif ( $x = $y )
{
echo "</tr>\n";
}
else
{
echo "</tr>\n";
}
}
Thanks,