I have some problems creating a table that will display pictures from a php database
This is my code:
$query = "SELECT * FROM images ORDER BY name ASC ";
$result = $db->query($query);
$num_result = $result->num_rows;
echo "<h1> Images</h1>";
$array = array();
for ($i = 0; $i < $num_result; $i++){
$row = $result->fetch_assoc();
$name = $row['name'];
$URL = $row['imageURL'];
$array[] = $URL;
}
//this loop is printing the images correctly in order
foreach ($array as $image){
echo '<img src="'.$image.'"/>';
}
What I am trying to accomplish is to create a table with 2 Columns that will print the images there, something like this
echo '<table>';
echo ' <tr>';
echo ' <td>image 1</td>';
echo ' <td>image 2</td>';
echo ' </tr>';
echo ' <tr>';
echo ' <td>image 3</td>';
echo ' <td> image 4</td>';
echo ' </tr>';
// and so on if there is more images
echo '</table>';
Any suggestions will help , Thanks!