Image display though sql

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
dave3460
Posts: 117
Joined: Wed Jul 01, 2009 2:13 pm

Image display though sql

Post by dave3460 »

Hey guys could i get some advice on displaying images using sql and php.
i have got a auction database set up and running just in text .
But would like to get the images to link to it the only issue is i have got a seperate database for items with images and my auction is displayed from a api so i only get the item text name .
That why i have the images in a seperate database but would love to able to link the name of my image to the name of text. i have been trying to work this out .i can get the images to display but it doesnt pick the name i am after .
Thanks in advance if you can help with this issue
Dave
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Image display though sql

Post by Torniquet »

i would name the images the same as the item names.

so...

item: WoodenSword
image file name: WoodenSword.png


then create a new variable to hold the root and file name of you image...

$image = "../images/items/" . $itemName . ".png";

echo "<img src='$image' />

that should work just nicely.
New Site Coming Soon! Stay tuned :D
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Image display though sql

Post by Jackolantern »

That is definitely a better setup. Holding the images in the database will put a ton of unneeded strain on MySQL.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Image display though sql

Post by hallsofvallhalla »

i show this in Urban Realms videos. Like Torn said, all you store is the file name, then echo it out as a image.
dave3460
Posts: 117
Joined: Wed Jul 01, 2009 2:13 pm

Re: Image display though sql

Post by dave3460 »

thanks guys
Post Reply

Return to “Advanced Help and Support”