I am using PHP, HTML, and MySQL to build a website.
So, my goal is to make an image gallery for my webpage which should display only 3 images each row.
But my code seems wrong and I do not know where should I do the correction.
-) Here is my code:
$query = mysql_query("SELECT DISTINCT * FROM products WHERE catID = 11 ORDER BY typeID ASC");
echo "<table>";
while ($row = mysql_fetch_assoc($query))
{
echo "<tr>";
for ($c = 0; $c < 3; $c += 1){
echo "<td>";
echo '<img src="data:image/jpg;base64,'.base64_encode($row['productImg'] ).'" width="300" height="200" alt=""
/>';
echo "<br>";
echo "<b>";
echo $row['productName'];
echo "</b>";
echo "<br>";
// More detail button set up
?><a href="show.php?productID=<?php echo $row["productID"]; ?>">More Detail <i class="fa fa-arrow-circle-o-right"></i></a> <?php
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
-) Here is the result: wrong result image
The result turns out not what I expected since on 1 row it displays 3 same images. What I wanted is to display 3 different images on each row. I do not know where I did wrong.