0

Hi There Everyone.

Could anyone assist me in the correct method of displaying images from my mysql db. I want to display multiple images on my page.

This is the code I have. I got this from a post from DaniWeb. Hope I did the code tags correctly.

<?php

require 'library/config.php';
require 'library/opendb.php';
?>
<?php
header('Content-type: image/JPG');

@mysql_connect($dbhost, $dbuser, $dbpass) or die("Can not connect to database: ".mysql_error());
@mysql_select_db($dbstore) or die("Can not select the database: ".mysql_error());

$query = mysql_query("SELECT id, type, content FROM upload");
while($row = mysql_fetch_array($query)){
print $row['content'];
}
?>

Thanks allot.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by deleted1234
0

What data type did you use for 'content?' Is it blob?
I think it would be better if you don't save the image itself on the database. Instead save just the file name and path where it was uploaded. When you have the path you can then show the images by doing <img src = '<?php echo $content ?>'>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.