I have only been able to display the replication of one image, despite have more than one image in my folder. So if I have three images in my folder, my code is only able to show the first image 3 times. Please help me with this code. Thanks. I have posted my code for you to help.
Call_images.php
$imgLocation = '/upload/';
$sql = "select * from myTable";
$result = mysql_query($sql) or die ("Could not access DB: " .
mysql_error());
while ($row = mysql_fetch_array($result)) {
$row = mysql_fetch_array($result);
$imgName = $row["filename"];
$imgPath = $imgLocation . $imgName;
// Make sure the file exists
if(!file_exists($imgPath) || !is_file($imgPath)) {
header('HTTP/1.0 404 Not Found');
die('The file does not exist');
}
// Make sure the file is an image
$imgData = getimagesize($imgPath);
if(!$imgData) {
header('HTTP/1.0 403 Forbidden');
die('The file you requested is not an image.');
}
// Set the appropriate content-type
// and provide the content-length.
header("Content-Type: " . $imgData['mime']);
header("Content-length: " . filesize($imgPath));
// Print the image data
readfile($imgPath);
exit();
}
?>
image.php
<?php
// Grab the data from our people table
$sql = "select * from myTable";
$result = mysql_query($sql) or die ("Could not access DB: " .
mysql_error());
$imgLocation = "/uploadz/";
while ($row = mysql_fetch_array($result))
{
$imgName = $row["filename"];
$imgPath = $imgLocation . $imgName;
echo "<img src=\"call_images.php?imgPath=" . $imgName . "\" alt=\"\"><br/>";
}
?>