echo '<table>';
echo '<tr>';
$i = '';
while($res = mysql_fetch_assoc($mysqlqry)){
echo '<td><a href="'. $res['link'] .'"><img src="'. $res['link'] .'" style="border: 0px; width: 150px; height: 150px;" alt="afbeelding"></a></td>';
$i++;
if($i = '4'){
echo '</tr><tr>';
}
}
echo '</tr>';
echo '</table>';
I want to set a max of 4 <td>s, then set a new <tr> when I get something from a mysql table, only this is not w3 valid and not working.
How can I make this work, and set other <td>s when there are less then 8 results?
Your problem is this:
That’s assigning
'4'to$i. You probably want to do something like:In other words, every time
$idivided by four is an even division (there’s no remainder), start a new<tr>.