Author Topic: help with mysql and creating link to images  (Read 1216 times)

0 Members and 1 Guest are viewing this topic.

Offline blagojkkTopic starter

  • Irregular
  • Posts: 6
    • View Profile
help with mysql and creating link to images
« on: December 12, 2006, 07:11:32 AM »
I have one table in the mysql database. I want to setup a field that links to an image on my server so I need someone to tell me how to set up the field and make the link entry? After that I heed to display that image using this link in a web browser with some PHP form.

For examle my databse name is 'imagedb', my table name is 'imagetbl' and my field name is fieldimg'. My image is in /var/www/html/images/image1.jpg.

Thanks

Offline artacus

  • Devotee
  • Posts: 915
  • Gender: Male
  • World domination? Never heard of it.
    • View Profile
    • Flex and Specs()
Re: help with mysql and creating link to images
« Reply #1 on: December 12, 2006, 11:25:51 PM »
Well don't link to the local filesystem. You need to link either relative to the current directory or the root of your webserver. I'd probably only store the actual file name if they are all going to be in images/
Code: [Select]
if($row['fieldimg']) {
    $img = "<img src='/images/$row[fieldimg]'>";
}
   
}
artacus

-- Trust your leaders, depend on your government, don't question the media... and this won't hurt a bit. --

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: help with mysql and creating link to images
« Reply #2 on: December 15, 2006, 06:59:08 PM »
Agreed -- you can always store the path somewhere else in the DB, or hard-code it somewhere.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.