- <?php
-
//header('Content-Type: image/jpeg');
-
header('Content-Type: text/html');
-
@mysql_connect("localhost","root","dba") or die("Error");
-
@mysql_select_db("gallery");
-
$result = mysql_query("SELECT * FROM paintings");
-
while($row = mysql_fetch_assoc($result)){
-
print $row[p_painting_id]."</br>";
-
//print $row[p_painting_image];
-
}
-
?>
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!!! -
<?php
-
header('Content-Type: image/jpeg');
-
//header('Content-Type: text/html');
-
@mysql_connect("localhost","root","dba") or die("Error");
-
@mysql_select_db("gallery");
-
$result = mysql_query("SELECT * FROM paintings");
-
while($row = mysql_fetch_assoc($result)){
-
//print $row[p_painting_id]."</br>";
-
print $row[p_painting_image];
-
}
-
?>
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
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).
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.
pbmods 5,821
Recognized Expert Expert
NSE, Please use CODE tags when posting source code:
[CODE=PHP]
PHP code goes here.
[/CODE]
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.
thanks all :) for the info on tags, links n abt the advice on attitude arnd here :)
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 -
<?php
-
error_reporting(E_ALL);
-
if(isset($_GET['image_id']) && is_numeric($_GET['image_id'])) {
-
$link = mysql_connect("localhost", "root", "password") or die("Could not connect: " . mysql_error());
-
mysql_select_db("demodb") or die(mysql_error());
-
$sql = "SELECT img_data FROM images WHERE img_id={$_GET['image_id']}";
-
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
-
header("Content-type: image/jpeg");
-
echo mysql_result($result, 0);
-
mysql_close($link);
-
}else{
-
echo 'Please use a real id number';
-
}
-
?>
-
Send Http GET request to the image.php file to print your inline images from your second page. another_page.php -
<?php
-
error_reporting(E_ALL);
-
$link = mysql_connect("localhost", "root", "password") or die("Could not connect: " . mysql_error());
-
mysql_select_db("demodb") or die(mysql_error());
-
$sql = "SELECT img_id FROM images";
-
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
-
while($row=mysql_fetch_assoc($result)){
-
print "Image : ".$row['img_id'];
-
print '<img src="image.php?image_id='.$row['img_id'].'"/>';
-
}
-
mysql_close($link);
-
?>
-
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
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.
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
thank you so much ak1dnar
it was so much helpful content....
thanks again :))
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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!
|
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...
|
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....
| |
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...
|
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
|
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...
|
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...
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |