Hi.
Is the image itself (the data) inside the database, or just a link to where it is stored on the file-system?
If it is the first one, you have to fetch the image by itself and output it as an image by setting the headers.
That is generally done by creating a separate script that fetches and outputs the image, which is then called by tags, just like an image.
For example:
<?php
/**
* File: list.php
*/
$sql = "SELECT id, name FROM myTbl";
$result = mysql_query($sql);
echo '<table>';
while($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo ' <td>{$row['name']}</td>';
echo ' <td><img src="img.php?id=', $row['id'], '" alt="" /></td>';
echo '</tr>';
}
echo '</table>'; <?php
/**
* File: img.php
*/
($id = @$_GET['id']) or $id = null;
if(!$id or !is_numeric($id) or $id <= 0) {
die("ID is invalid");
}
$sql = "SELECT imageData, imageMime FROM myTbl WHERE id = {$id}";
$result = mysql_query($sql);
if(mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
header("content-type: {$row['imageMime']}");
header("content-length: ", strlen($row['imageData']));
echo $row['imageData'];
}
else {
echo "Image doesn't exist";
}
?> Executing list.php would then give you a table of names and images.