Already you know how to upload images to mysql database using php. Otherwise, visit upload images to mysql database using php.
The php script for retrieve images from mysql database is:
where,
mysql_query() select the row which is no '1' from mysql database.
mysql_fetch_array() return the result an associated array. You want to know about mysql fetch array().
In your img src print image name with location of image. Now you''ll get output like this:
Related Post:
Retrieve images from database:
Normally you can retrieve data from mysql table using php. Then you print the result. Similarly you retrieve image name from mysql database and print image name with located folder in '<img>' tag.
Consider following mysql table.
The php script for retrieve images from mysql database is:
<?php
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('new') or die(mysql_error());
$q=mysql_query("select * from image where no=1 ") or die(mysql_error());
$res=mysql_fetch_array($q);
?>
<img src="<?php echo 'http://localhost/upload/image/'.$res['img_name'];?>">
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('new') or die(mysql_error());
$q=mysql_query("select * from image where no=1 ") or die(mysql_error());
$res=mysql_fetch_array($q);
?>
<img src="<?php echo 'http://localhost/upload/image/'.$res['img_name'];?>">
where,
mysql_query() select the row which is no '1' from mysql database.
mysql_fetch_array() return the result an associated array. You want to know about mysql fetch array().
In your img src print image name with location of image. Now you''ll get output like this:
Related Post: