I am having trouble with displaying images with php. I have tried the following How to retrieve images from MySQL database and display in an html tag, but it's still not displaying properly.
I have a php file that is handling the html format, the code for the image part is as follows:
while($row = mysql_fetch_array($result)) {
$partNo = $row['partNo'];
echo "<tr>";
echo '<td> <img src="getThumb.php?id =\''. $partNo .'\' width="50" height="50" /> </td>';
My getThumb.php is as follows:
<?php
$id = $_GET['id'];
$con = mysql_connect("localhost", "root", "root") or die("Unable to connect to server");
mysql_select_db("bmworld.mu");
$sql = "SELECT thumbnail FROM part WHERE partNo=$id" or die ("Could not fetch thumbnail");
$result = mysql_query("$sql");
$row = mysql_fetch_object($result);
mysql_close($con);
header("Content-type: image/jpeg");
echo $row['thumbnail'];
?>
The results is as follows:
Help please.
Aucun commentaire:
Enregistrer un commentaire