473,498 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Blob does not display multiple images from mysql database

21 New Member
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //header('Content-Type: image/jpeg');
  3. header('Content-Type: text/html');
  4. @mysql_connect("localhost","root","dba") or die("Error");
  5. @mysql_select_db("gallery");
  6. $result = mysql_query("SELECT * FROM paintings");
  7. while($row = mysql_fetch_assoc($result)){
  8. print $row[p_painting_id]."</br>";
  9. //print $row[p_painting_image];
  10. }
  11. ?>
this code displays all the painting ids available in the table 'gallery'.

but the below coding doesnt display all the corresponding images(of blob type).
Please tell em why.thanks in advance!!!
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header('Content-Type: image/jpeg');
  3. //header('Content-Type: text/html');
  4. @mysql_connect("localhost","root","dba") or die("Error");
  5. @mysql_select_db("gallery");
  6. $result = mysql_query("SELECT * FROM paintings");
  7. while($row = mysql_fetch_assoc($result)){
  8. //print $row[p_painting_id]."</br>";
  9. print $row[p_painting_image];
  10. }
  11. ?>
Jul 29 '08 #1
11 10789
dlite922
1,584 Recognized Expert Top Contributor
check out this tutorial:

http://www.phpriot.com/articles/images-in-mysql/8


Get it? Got it? Good.




Dan
Jul 29 '08 #2
nse111
21 New Member
Gosh stop being rude! by the way thanks for that link but that also explains displaying just ONE image. see thats the prob I'v got. I want to display multiple images (thumbnail list).
Jul 29 '08 #3
pbmods
5,821 Recognized Expert Expert
Heya, NSE.

To display multiple images, you have two options. You can either inline your image data (http://www.elf.org/essay/inline-image.html), or you can create a viewimage.php page that grabs a single image, and then create a bunch of <img /> tags that link to that page.
Jul 29 '08 #4
pbmods
5,821 Recognized Expert Expert
NSE, Please use CODE tags when posting source code:

[CODE=PHP]
PHP code goes here.
[/CODE]
Jul 29 '08 #5
Markus
6,050 Recognized Expert Expert
Gosh stop being rude! by the way thanks for that link but that also explains displaying just ONE image. see thats the prob I'v got. I want to display multiple images (thumbnail list).
It's all light-hearted 'round these parts! He wasn't being rude.

Kind regards.
Jul 29 '08 #6
nse111
21 New Member
thanks all :) for the info on tags, links n abt the advice on attitude arnd here :)
Jul 29 '08 #7
ak1dnar
1,584 Recognized Expert Top Contributor
Please read this simple example to find out what "pbmod" said.

Create your first script to print a single image based on a image id. image.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. error_reporting(E_ALL);
  3. if(isset($_GET['image_id']) && is_numeric($_GET['image_id'])) {
  4. $link = mysql_connect("localhost", "root", "password") or die("Could not connect: " . mysql_error());
  5. mysql_select_db("demodb") or die(mysql_error());
  6. $sql = "SELECT img_data FROM images WHERE img_id={$_GET['image_id']}";
  7. $result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
  8. header("Content-type: image/jpeg");
  9. echo mysql_result($result, 0);
  10. mysql_close($link);
  11. }else{
  12.     echo 'Please use a real id number';
  13. }
  14. ?>
  15.  
Send Http GET request to the image.php file to print your inline images from your second page.

another_page.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. error_reporting(E_ALL);
  3. $link = mysql_connect("localhost", "root", "password") or die("Could not connect: " . mysql_error());
  4. mysql_select_db("demodb") or die(mysql_error());
  5. $sql = "SELECT img_id FROM images";
  6. $result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
  7. while($row=mysql_fetch_assoc($result)){
  8. print "Image : ".$row['img_id'];
  9. print '<img src="image.php?image_id='.$row['img_id'].'"/>';
  10. }
  11. mysql_close($link);
  12. ?>
  13.  
Jul 29 '08 #8
mms003
3 New Member
Thanks ak1dar
I was looking for this for the past 2 weeks...
This works good...
Got more question.
How do I display more info from same database? Example title and so on...
And sort by date.
I want to create where a registered user can up load 10 images and put it in its won area… and display the name of the photos the person upload by most resent.

Thanks in advance
Aug 21 '08 #9
mms003
3 New Member
Ok I got it to display different information and created a table to center the image...

no I need to know how to create table's within tables... when a user upload all 10 images it keeps it separated form the rest...

Thanks.
Aug 21 '08 #10
ak1dnar
1,584 Recognized Expert Top Contributor
Hi mms003,

I think you can print blob data as images now. glad to help. but your second question is not matching with this thread title. so how about creating a new thread. Please read some posting guidelines too. And also welcome to the forum. See you again.
Posting Guidelines
posting guidelines
-ak1dnar
Aug 22 '08 #11
thank you so much ak1dnar
it was so much helpful content....
thanks again :))
Oct 13 '10 #12

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

Similar topics

7
7066
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and...
5
2660
by: Bob Kaku | last post by:
I've created a MySQL database to store a large amount of text. Since the text data type in MySQL is limited to 255 characters, I added a BLOB column. I created an PHP input screen to enter the...
3
3130
by: NotGiven | last post by:
I am researching the best place to put pictures. I have heard form both sides and I'd like to know why one is better than the other. Many thanks!
3
10423
by: adam | last post by:
Hi, I have an issue that i just cant seem to figure out hope some one can help. right i am getting people to input the own images directly into a blob within a mysql database. then on the next...
1
2983
by: konsu | last post by:
Hello, I am planning to implement an image and movie library (e.g. a photoalbum), and one of the ways that I see to store image and movie files is to put them in to BLOB fields in an sql table....
3
4697
by: hamvil79 | last post by:
I'm implementig a java web application using MySQL as database. The main function of the application is basically to redistribuite documents. Those documents (PDF, DOC with an average size around...
2
4487
by: Olav Tollefsen | last post by:
How can I display photo images stored in a SQL Server 2000 databases in a DataList or DataGrid without having to write the images to files first? Olav
2
5216
by: Adam | last post by:
I have extensively searched for a solution. Below is my code that is contained in an aspx. When my browser hits this aspx, I just get the standard broken image picture. I know the data is the...
55
24659
ADezii
by: ADezii | last post by:
Of all the questions asked here at TheScripts, the one which appears with the most frequency relates to the storing of Graphic Images within Access. There are basically three techniques available to...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.