I’ve create a table where I’ve saved images through “BLOB”. I need to show those images along with other items. But I don’t know how to show those images together in the same page.
Here’s my php code that displays other things in form of a table. Similarily, I wanted to display images accordingly. Any help?
<?php
$display_query = mysql_query("SELECT * FROM eportal");
echo "<table id='pageTable'><thead><tr><th>Item code</th><th>Description</th><th>Cost</th></tr></thead>";
echo "<tbody>";
while($row = mysql_fetch_array($display_query)){
print "<tr><td>".$row['itemid']."</td><td>".$row['description']."</td><td>";
print "₹".$row['cost']."</td></tr>";
}
echo "</tbody>";
echo "</table>";
mysql_close($connection);
?>
As other people mentioned, storing the images in the database is usually a bad idea.
Images are not transmitted in the same
HTTPresponse with another page data.To show images from the database, you would need to implement a script which, given the item id, would read the field and send the image’s binary data; and provide the path to the script in your form’s
<img src="">:image.phpis another script which outputs the value ofimage_blobgiven theeportal.id. You would also need to provide correct size and mime type in the headers.You better just store the images in a file (accessible by the web server) and store the path fo the file in the database.