Page 1 of 1

Image display though sql

Posted: Sat Mar 27, 2010 3:32 pm
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

Re: Image display though sql

Posted: Sat Mar 27, 2010 8:43 pm
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.

Re: Image display though sql

Posted: Mon Mar 29, 2010 1:38 am
by Jackolantern
That is definitely a better setup. Holding the images in the database will put a ton of unneeded strain on MySQL.

Re: Image display though sql

Posted: Mon Mar 29, 2010 2:23 am
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.

Re: Image display though sql

Posted: Mon Mar 29, 2010 12:00 pm
by dave3460
thanks guys