Here is a php line in one of my prog's.
<?
$query=("select * from inventory_sales order by manufacturer");
$result=mysql_query($query);
for
($i = 0; $i < mysql_num_rows($result); $i++) {
while ($row = mysql_fetch_array($result)) {
echo "
<img src='../forsale/$row[id].gif'>"
}}
?>
This logic pulls all the picture locations from a db, then plugs that value into an img src html line, which the browser reads and then places the image.
Hope this helps