Page 1 of 1

Help!!!how can i display images from DB

Posted: Mon May 15, 2006 5:19 pm
by Melz6682
I am a newbie to php and mysql. i have a questions.

What's the best way to save images to my database and display them into my php page. I created a page http://www.it2o.com/nadir4, and there are articles that display images within them, so how can i save my images through an upload form, then post them to the database and from there display them into the page? . I created an upload page http://www.it2o.com/nadir4/upload_info.html
Thanks alot...your help is appreciated

Posted: Mon May 15, 2006 5:46 pm
by hawleyjr
You really don't want to store the physical image to the database. store a link to the image in the database instead. :idea:

Posted: Mon May 15, 2006 5:54 pm
by Melz6682
Thanks
So how can i upload the images to the database using an upload form. And once the images are in the database, what would the link be like. I mean the images don't reside in a folder so u can point to them like you would in HTML, they will reside in the database

Posted: Mon May 15, 2006 6:04 pm
by hawleyjr
I HIGHLY recomend that you don't do it this way. but here is a tutorial to help you... :wink:

Posted: Mon May 15, 2006 6:10 pm
by Melz6682
if this is a bad idea, what do you suggesst is the best idea to display images?

Posted: Mon May 15, 2006 7:50 pm
by John Cartwright
store the filepath to the image instead of the actual image itself, for example store /images/jcart.jpg inside a row.. then when fetching the data

Code: Select all

echo '<img src="'.$row['image_path'].'">';

Posted: Mon May 15, 2006 8:32 pm
by Todd_Z
I go to a certain city's meetup and there is a DBA present who brags that he/she has a database with millions of images stored in it. They are very proud of this setup and all the old folks oo and aaa at the fact that she can store so much crap in a database and still have the computer in a somewhat usefull state.

Am I the only one who would never put so many files in a database like that, or am I just a jackass for feeling superior to this man/woman?

It may be harsh, but there seems to be a red sports car effect on databases these days. Meaning people just go for the outside figures: an umpteen thousand rows, uberty-five columns, and shventy-pi indices. Give me a well designed database which is as efficient as possible, and I'll be impressed. Throw a couple terabytes into a database, and I will scoff.

Just my 0.02