arsis Posted January 16, 2009 Share Posted January 16, 2009 Hey I've been having a bit of trouble with this. My final product is going to be a table with data and a Snapshot that is paginated across however many pages. With my current code I've gotten a data table that displays MySQL data and paginates it correctly, the only thing I am stuck on is the ability to retrieve BLOB type jpegs. With this code I am able to fetch the image but just as raw text, I suppose its just dumping the image as characters, but it works none the less... I just need to let it know to display it as a jpeg image. $sql_query = "SELECT `Snapshot` FROM `DoorEvents` ORDER BY `DoorEvents`.`Id` ASC LIMIT 0,1 ";// MySQL query and formatting $result = @MySQL_query($sql_query, $conn); while ($row = mysql_fetch_assoc($result)) { // echo data echo "<img src=".$row['Snapshot'].". alt='photo'>"; I know this isnt the way to do it... buts its a step in the right direction. Can anyone point me in the right one? Quote Link to comment https://forums.phpfreaks.com/topic/141115-fetching-blob-images-from-mysql-in-php/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 16, 2009 Share Posted January 16, 2009 Images require a URL that when fetched by the browser outputs the proper content type header for the image, followed by the image data - http://w3schools.com/html/html_images.asp The URL you supply in your <img src="..."> tag would be to a .php page that gets the correct image from the database, outputs a header and the image data. Quote Link to comment https://forums.phpfreaks.com/topic/141115-fetching-blob-images-from-mysql-in-php/#findComment-738625 Share on other sites More sharing options...
arsis Posted January 16, 2009 Author Share Posted January 16, 2009 Images require a URL that when fetched by the browser outputs the proper content type header for the image, followed by the image data - http://w3schools.com/html/html_images.asp The URL you supply in your <img src="..."> tag would be to a .php page that gets the correct image from the database, outputs a header and the image data. Thanks, So like point it to a "getimage.php" or something? I need to output all the images in the Snapshot row, not just a specific one... Quote Link to comment https://forums.phpfreaks.com/topic/141115-fetching-blob-images-from-mysql-in-php/#findComment-738661 Share on other sites More sharing options...
The Little Guy Posted January 17, 2009 Share Posted January 17, 2009 You will need to link to the php file, and that file will have to build the image using some of the GD Functions. Quote Link to comment https://forums.phpfreaks.com/topic/141115-fetching-blob-images-from-mysql-in-php/#findComment-738801 Share on other sites More sharing options...
corbin Posted January 17, 2009 Share Posted January 17, 2009 You will need to link to the php file, and that file will have to build the image using some of the GD Functions. GD won't need to be used since he's storing a binary representation of the image. Quote Link to comment https://forums.phpfreaks.com/topic/141115-fetching-blob-images-from-mysql-in-php/#findComment-738812 Share on other sites More sharing options...
PFMaBiSmAd Posted January 17, 2009 Share Posted January 17, 2009 Each image requires an <img src="..."> tag. Quote Link to comment https://forums.phpfreaks.com/topic/141115-fetching-blob-images-from-mysql-in-php/#findComment-738813 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.