Help!!!how can i display images from DB

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Melz6682
Forum Newbie
Posts: 4
Joined: Mon May 15, 2006 5:15 pm

Help!!!how can i display images from DB

Post 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
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post 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:
Melz6682
Forum Newbie
Posts: 4
Joined: Mon May 15, 2006 5:15 pm

Post 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
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

I HIGHLY recomend that you don't do it this way. but here is a tutorial to help you... :wink:
Melz6682
Forum Newbie
Posts: 4
Joined: Mon May 15, 2006 5:15 pm

Post by Melz6682 »

if this is a bad idea, what do you suggesst is the best idea to display images?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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'].'">';
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post 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
Post Reply