You are echoing the entire table for each time you get a picture from the database.
To do this you will need to output the start of the table then the images then the end of the table.
<table><?php...?></table>
Additionally, you will need to do something more complex: create <td> EVERY time, and create <tr> every 3RD time.
So the easiest way to do this is to use the while loop like you have but to store the images into an array:
PHP Code:
while ($row = mysql_fetch_assoc($queryresult)) {
$myimgs[] = $row['img'];
}
(roughly)
Now after this is where it gets complex:
PHP Code:
echo '<table><tr>';
for($x=0;$x<count($myimgs);$x++) {
if ($x%3==0) { echo '</tr>'; }
echo '<td><img...src="'.$myimgs[$x].'"></td>';
}
echo '</tr></table>';
There are other ways to organize this, but that seems like (perhaps) the most straightforward. The tricky part is executing the <tr> every 3rd time. For this it's important to have a number you can count (here it's $x). Using just the while loop it's not that easy. You could integrate the two, but that would be more complex...
Bookmarks