I am trying to display images (and other data connected to them, e.g. titles) in a table. The filenames of the images are stored in my database as imgname
, but the problem is that there is only one image that is being displayed.
Here is the code I use. What should I change?
mysql_select_db($database_connection, $connection);
$query_img = "SELECT imgname FROM img ORDER BY imgname";
$img = mysql_query($query_img, $connection) or die(mysql_error());
$row_img = mysql_fetch_assoc($img);
$totalRows_img = mysql_num_rows($img);
Table
<ul>
<li>
<img src="images/<?php echo $row_img['imgname']; ?>">
<h3><?php echo $row_title['title']; ?></h3>
<p><?php echo $row_description['des']; ?></p>
</li>
<li>
<img src="images/<?php echo $row_img['imgname']; ?>">
<h3><?php echo $row_title['title']; ?></h3>
<p><?php echo $row_description['des']; ?></p>
</li>
<li>
<img src="images/<?php echo $row_img['imgname']; ?>">
<h3><?php echo $row_title['title']; ?></h3>
<p><?php echo $row_description['des']; ?></p>
</li>
</ul>
Since I use a simmilar code for the titles and descriptions, I have the same problem with them.