Pictures In Database
How can i do it?
Page 1 of 1
Pictures In Database How can i do it?
#1
Posted 19 April 2007 - 03:16 AM
Hi,
how would i go about storing pictures in a database & then echoing them
how would i go about storing pictures in a database & then echoing them
#2
Posted 19 April 2007 - 04:51 AM
Man2u2uk, on Apr 19 2007, 09:16 AM, said:
Hi,
how would i go about storing pictures in a database & then echoing them
how would i go about storing pictures in a database & then echoing them
you would be taking advantage of the the BLOB fields in databases.
However, this is NOT a good idea to do with images any bigger then thumbnails. As your putting a lot of stress on the mysql server if you do, which some hosts do not allow. I really reccomend uploading the file and then saving the path to the file in the database instead.
however, i will answer your question breifly..
$image = addslashes(@fread(@fopen($dir.'/'.$file, "r"), @filesize($dir.'/'.$file))))
Then $image is ready for an INSERT statement..
to retrieve, something like this, after a SELECT query.
$image = $r['myimage'];
header("Content-type: image/gif");
print $image;
Agin i need to WARN you from doing this. its really not the best option.
EDIT
Read this: http://www.webmaster...orum88/9091.htm
#3
Posted 19 April 2007 - 05:02 AM
Thanks,
all i need to do is echo pictures from my databse on a catalog page. (its only for university work)
the pictures only really need to be thumbnail size anyway
all i need to do is echo pictures from my databse on a catalog page. (its only for university work)
the pictures only really need to be thumbnail size anyway
#4
Posted 19 April 2007 - 08:12 AM
Hey,
Is this for the Web Project or Intro to Internet Apps one - because for the Web Project, I've got a similar thing for products.
In the database each product has an ID, and I just use that ID as the name (or part of) of the product image.
For example, one product could be ID number 48, and the image is in the folder images/products/48.jpg
Then I use PHP to build up the image string using to ID where needed.
Make sense?
Is this for the Web Project or Intro to Internet Apps one - because for the Web Project, I've got a similar thing for products.
In the database each product has an ID, and I just use that ID as the name (or part of) of the product image.
For example, one product could be ID number 48, and the image is in the folder images/products/48.jpg
Then I use PHP to build up the image string using to ID where needed.
Make sense?
#5
Posted 19 April 2007 - 08:54 AM
Thanks ben,
i managed to do it by storeing the images URL in the database: i.e http://www.google.com/images/bike.jpg
then searching for it: $prod_pic=mysql_result($result,$i,"prod_pic");
then echoing it: <? echo "<img src=\"$prod_pic\" />"; ?>
i managed to do it by storeing the images URL in the database: i.e http://www.google.com/images/bike.jpg
then searching for it: $prod_pic=mysql_result($result,$i,"prod_pic");
then echoing it: <? echo "<img src=\"$prod_pic\" />"; ?>
#7
Posted 19 April 2007 - 09:36 AM
Glad you didnt use Binary file in mysql
#8
Posted 17 May 2011 - 07:56 AM
Man2u2uk, on 19 April 2007 - 08:54 AM, said:
Thanks ben,
i managed to do it by storeing the images URL in the database: i.e http://www.google.com/images/bike.jpg
then searching for it: $prod_pic=mysql_result($result,$i,"prod_pic");
then echoing it: <? echo "<img src=\"$prod_pic\" />"; ?>
i managed to do it by storeing the images URL in the database: i.e http://www.google.com/images/bike.jpg
then searching for it: $prod_pic=mysql_result($result,$i,"prod_pic");
then echoing it: <? echo "<img src=\"$prod_pic\" />"; ?>
we had the same idea..
Share this topic:
Page 1 of 1


Help
This topic is locked
MultiQuote










