I got a script which displays the image from mysql table.
Here's my script:
testgetpicture.php
<?php
// just so we know it is broken
error_reporting(E_ALL);
// some basic sanity checks
if(isset($_GET['image_id']) && is_numeric($_GET['image_id'])) {
//connect to the db
$link = mysql_connect("localhost", "root", "") or die("Could not connect: " . mysql_error());
// select our database
mysql_select_db("templetree") or die(mysql_error());
// get the image from the db
$sql = "SELECT content FROM sample_design WHERE image_id=".$_GET['image_id'];
// the result of the query
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
// set the header for the image
header("Content-type: image/jpeg");
echo mysql_result($result, 0);
// close the db link
mysql_close($link);
}
else {
echo 'Please use a real id number';
}
?>
But it allows me to display image only by specifying its id.
EX. display_image.html
<html> <body> <img src="testgetpicture.php?image_id=1"/> </body> </html>
This way i'll have to display each image by specifying its image id individually. Is there any way where I can display all the images (from database table) in a row or column without specifying a specific image id?
Please let me know whether it is possible or not.
Thanks in advance.


Sign In
Create Account


Back to top










