473,378 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how do i display an image from the database?

2
Hello I am new to the database world and Ive learned how to do a few things storing text is easy. i found that out but trying to get an image to show up on a page is difficult and i cant seem to find the correct way to call it up in php so it will display..What i am trying to do is build a search engine for a furniture companys rug collection...so that the rug type style size and an image next to that will show up...

this is my php code
[php]<?php # rug search_results.php
$connection = mysql_connect('*', '*', '*') or die(mysql_error());
if (!$connection) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("rugs", $connection);
$rugtype_id = "";
if (isset($_GET['rugtype_id'])) {
$rugtype_id = $_GET['rugtype_id'];
}
if ($rugtype_id != NULL) {
$query = "SELECT * FROM rugs WHERE rugtype_id=$rugtype_id";
$result = mysql_query($query, $connection);
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "{$row['itemnumber']}";
echo "<br />";
echo "{$row['rugname']}";
echo "<br />";
echo "{$row['origin']}";
echo "<br />";
echo "{$row['fabric']}";
echo "<br />";
echo "{$row['image']}";

} // End of WHILE loop.
}
else { // No
echo '<p class="error">';
echo "There are no rugs listed for the given request.";
echo "</p>";
}
}
else {
echo '<p class="error">';
echo "Please select a valid rug type from the drop-down menu in order to view the rugs.";
echo "</p>";
}
?>[/php]please tell me what im doing wrong any input would help thanks

Dan
Feb 27 '08 #1
5 1332
Markus
6,050 Expert 4TB
Have a look at this tutorial.
Feb 27 '08 #2
ronverdonk
4,258 Expert 4TB
Welcome to TSDN!
please tell me what im doing wrong any input would help thanks
What you are doing wrong anyway is NOT enclosing your code within coding tags! You make it hard on our members to help ytou when you present them with messy formatted code.

See the Posting Guidelines.

moderator
Feb 27 '08 #3
ronverdonk
4,258 Expert 4TB
Your thread title is 'How to upload an image blob', but from your code the image is already in the database and your question is about displaying an image.

If the latter is the case, you should have a look at thread Showing an image from the database because that handles this problem.

Ronald
Feb 27 '08 #4
howzy
2
thanks to all

yes the image data is already in the blob. But all i seem to be getting back is what looks like binary data and not the actual image..i would love to know if there is a way in php to bring up the image. Most of the tutorials i found are how to browse and add an image to a database...i just want people to do a search and then have the image of the item and details about the item to come up. so far i can get the details to show up but im having zero luck on getting the actual image to show.

thanks
Feb 27 '08 #5
ronverdonk
4,258 Expert 4TB
Look at the thread I showed you in my previous post. Exactly the same problem.

Ronald
Feb 27 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
1
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail...
1
by: Eric Keung | last post by:
Hi all, my case is I want to get an image from access database and I just know it's "OLE object" field type at access I also don't know how to insert it into access here is my code and it just...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
1
by: Objectifnet | last post by:
What I really want to do is to be able to link two pages together using an ID, The table involved displays an image stored on the File Server that has the image details stored in the Database called....
3
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating...
7
by: eholz1 | last post by:
Hello Group, Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine. I have a view.php page that is supposed...
1
by: amritranjan | last post by:
How to retrive image file from MS access database and display this in another JSPpage -------------------------------------------------------------------------------- This is my Jsp code for...
1
by: swethak | last post by:
Hi, I write the code to display images.But it will not display image.And also gives the error like that error : Notice: Undefined index: gim in F:\Facebook\pic_up.php on line 59 plz tell...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.