Hi,
I have some pictures in a MySQL database that i am able to retrieve and display. How ever, i want to display them as images in a gallery, but not able to.
The MySQL query is ok, it retrieves the images, i think the problem is with my PHP script. Any help would be greatly appreciated. Here is the code that displays a single image (which works fine)
include ("database.php");
if (!isset($_GET['id'])) { echo "<br />ERROR: id not specified "; }
$id = (int) $_GET['id'];
if ($id <= 0) { echo "<br />ERROR: Invalid id <br />"; }
$query = sprintf("SELECT * FROM property_images JOIN property ON property.id = property_images.property_id ORDER BY property_images.id DESC LIMIT 1");
$result = mysql_query($query, $db) or die('Error, query failed');
if (mysql_num_rows($result) == 0) { echo "Error: property has no images. "; }
$row = mysql_fetch_array($result);
extract($row);
header('Content-type: ' . $row['uploadedimage_type']);
header('Content-length: ' . $row['uploadedimage_size']);
echo $row['content'];
and this is what i've tried for displaying all images .... with no luck (blank page)
$query = sprintf("SELECT * FROM property_images JOIN property ON property.id = property_images.property_id ORDER BY property_images.id DESC LIMIT 0 , 30");
$result = mysql_query($query, $db) or die('Error, query failed');
if (mysql_num_rows($result) == 0) { echo "Error: property has no images. "; }
else {
while ($row = mysql_fetch_array($result)) {
extract($row); } // end while
header('Content-type: ' . $row['uploadedimage_type']);
header('Content-length: ' . $row['uploadedimage_size']);
echo $row['content']; } // end else