Image display for news articles

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

Image display for news articles

Post by hairyjim »

(Sorry if it is in the wrong forum)

Hi,

Im new to PHP so go easy!

I have created a MySQL database to store news articles with the following fields.

Title, Date, main article, smlImg, lgeImg

I created a script which lists all articles and then turns the title into the click through for the main detail. I want to display the image referenced in the db.

Now this is where my Q lies. Do I store the full path to the image in the DB or should I store only the name and create an image path variable in my detail page file?

What is the best practice solution?
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

If all of the images will be stored in one folder, or a folder you can construct from other variables, then I would create a path variable and only store the filename.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

just storing the filename makes your application more flexible, if say you wanted to change the path of the images at a later date

Mark
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

Post by hairyjim »

Thanks guys.

I did think it was perhaps the best way to do this just getting confirmation makes for more confidence in what I am trying to achieve.

:D
Post Reply