I am new to the programming – I am retrieving information from database and I have to display these items 3 per row.
Here is the code:
<?php
if($top) {
foreach($top as $val)
{
?>
<tr>
<?php for($c=0;$c<=3;$c++) { ?>
<td>
<img src="<?= $val['image']; ?>" style="width: 75px;height: 75px;"/>
</td>
<?php } ?>
</tr>
<?php
}
}
?>
but this shows same item 3 times in a row.
Unless this is actually tabular data I would display all the items in a list (
ul) and then simply display all thelis asinline-blockand give them 33% width:HTML
CSS
Edit: If you have to use a table, what you want to do is print a
</tr><tr>every third item. You can use modulus for this: