Reputation: 319
my aim is to pull data from mysql and print it in html table. asumming that 1,2,3...8 are the data
<table style="width: 100%">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
</table>
this is the code i have so far but this will only print out the column but no the row. plz help. thank you
<table style="width: 100%; color:aqua">
<?php
$showFoto = getFoto();
echo '<tr>';
foreach($showFoto as $Foto){
echo '<td class="afs"><img alt="" src="img/'.$Foto['img'].'.'.$Foto['ext'].'"><br>'.$Foto['about'].'</td>';
}
echo '</tr>';
?>
</table>
Upvotes: 0
Views: 324
Reputation: 54016
TRY
<table width ="100%" style="color:aqua" cellpadding="2" cellspacing="2">
<tr>
<?php
$showFoto = getFoto();
$i=0;
foreach($showFoto as $Foto){
++$i;
echo ($i%4==0) ? '</tr><tr>' :'';
echo '<td class="afs">
<img alt="" src="img/'.$Foto['img'].'.'.$Foto['ext'].'">'.$Foto['about'].
'</td>';
}
?>
</tr>
</table>
Upvotes: 1