![]() |
| ||
| Displaying images from mysql database I have successfully uploaded images into mysql database, but now I want to display the images alongside other row data in html page. Thanks for your previous help. Austin. |
| ||
| Re: Displaying images from mysql database something along these lines...you'll need to tweak it to fit your script, but you should get the idea... //connect to mysql with your variables here... |
| ||
| Re: Displaying images from mysql database Thanks Johnsquibb for the reply, Please see my code that I used to insert the image and other data. The image is inserted directly into the database. <?php $errmsg = ""; if (! @mysql_connect("localhost","root","")) { $errmsg = "Cannot connect to database"; } @mysql_select_db("adim"); if(isset($_REQUEST['submit'])) { $imgtype=$_FILES['uploadfile']['type']; $name=$_REQUEST['name']; $address=$_REQUEST['address']; $dateofbirth=$_REQUEST['dateofbirth']; if($imgtype=="image/jpeg" || $imgtype=="image/jpg" || $imgtype=="image/pjpeg" || $imgtype=="image/gif" || $imgtype=="image/x-png" || $imgtype=="image/bmp") { $image=$_FILES['uploadfile']['tmp_name']; $fp = fopen($image, 'r'); $content = fread($fp, filesize($image)); $content = addslashes($content); fclose($fp); $sql="insert into img_tab1 (name,image,address,dateofbirth) values ('$name','$content','$address','$dateofbirth')"; $res=mysql_query($sql) or die (mysql_error()); } } ?> Please further suggestions to display the whole row data including the image will be appreciated. Austin |
| ||
| Re: Displaying images from mysql database You can insert in the image table the path where you have saved your picture.Then display it like: <img src =\" ". $row['imageURL'] . "\"> |
| ||
| Re: Displaying images from mysql database i usually just insert the path to the location of the image, so I'm not well versed in storing the actual image data in and retrieving it from the database...I stumbled across this tutorial on google, however, so maybe it will be of use to you... http://www.spoono.com/php/tutorials/tutorial.php?id=42 |
| ||
| Re: Displaying images from mysql database yes we can insert the image data but it slows down the execution of the script and have high data filesize. |
| ||
| Re: Displaying images from mysql database Its not a good idea to store images in the database. As Ryan_vietnow has mentioned, it will add on to the server load, slows down the execution of the script and takes a lot of time to display it if you have more (say 100 images ) per page! |
| All times are GMT -4. The time now is 7:21 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC