Page 1 of 1
image query
Posted: Mon Jan 24, 2005 9:39 am
by Addos
Does anyone know of a tutorial that can help me set up a page that contains texts and images. I’m unsure how this is done but I’m converting over a lot of sites to PHP and I’m puzzled as to how to deal with this. Basically if I have a simple text page with an image on it and all this is stored in my MySQL database. This image itself is obviously under the root folder with the ext referenced from the database. But what happens if I need 2 or 3 images? Should I have 2 tables one linked to the other etc.
So if anybody has or can point me to a tutorial that would help me get this sorted I’d be most grateful
Ta
Brian
Posted: Tue Jan 25, 2005 4:37 pm
by RobertGonzalez
Basically if I have a simple text page with an image on it and all this is stored in my MySQL database. This image itself is obviously under the root folder with the ext referenced from the database. But what happens if I need 2 or 3 images? Should I have 2 tables one linked to the other etc.
Are you driving your content on each page from the DB? If you are you might want to consider a simple CMS tool to allow you to edit the entire body of your page (images, tables, etc) so when the page renders, what comes out of the db is the processed HTML code for the output. Just a thought.
If you are trying to pull text from the DB and images from a separate table in the DB, set your image table up so that you have a record_id field, a page_id field and an image_name field. Then when you hit the DB to grab the content you can join it to the image table on the page_id field. Then use the DB result anywhere you want to on the output page.
Hope that helps.
Posted: Fri Jan 28, 2005 5:25 am
by Addos
Thanks for your reply. I will look into this CMS tool as I have never heard of this before now.
Regards
B
Posted: Fri Jan 28, 2005 10:22 am
by RobertGonzalez
As a side note. using a Content Management System is not necessarily the best way to go for you. It might be easier but may not achieve what you want.
Another thing you can do is set up a table for your images in your DB (as I mentioned in my first reply). You can place as many images (or path references) as you want in the DB in a three field table (image_id, page_id, image_ref). Then when you run the script to load your page, run a query that grabs all images in the db that match the page id you are on. Store them in an array and place the array values where ever you want throughout yout page. This is just another idea. I guess in the end it really depends on what is easiest for you and what accomplishesthe task that you are on.
Posted: Fri Jan 28, 2005 10:25 am
by feyd
note: it's a drain on the system to store images inside the database.