Jump to content

displaying images from a database


kikilahooch

Recommended Posts

I'm trying to display images on my page which are stored on my server. I have a field in my product table which stores the name of the image. I am then doing an sql query to call the products that are belonging to a specific department. What I want to do is display all the images in a table belonging to the specific dept along with their price and name. When I carry out the sql stmt though it only returns the 1st image and it also displays the address where it is stored which i dont want. Any tips on how i get around this??


[code]
$sql ="select image, prodName ,price  from product where dept = 'mens'";

$imageDir = "http://snet.wit.ie/clothes/";
$imagePath = "$imageDir$image"

.....
<img src="<?php echo("$imagePath"); ?>"></font>[/code]
Link to comment
https://forums.phpfreaks.com/topic/7293-displaying-images-from-a-database/
Share on other sites

[!--quoteo(post=364340:date=Apr 13 2006, 11:23 AM:name=kikilahooch)--][div class=\'quotetop\']QUOTE(kikilahooch @ Apr 13 2006, 11:23 AM) [snapback]364340[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I'm trying to display images on my page which are stored on my server. I have a field in my product table which stores the name of the image. I am then doing an sql query to call the products that are belonging to a specific department. What I want to do is display all the images in a table belonging to the specific dept along with their price and name. When I carry out the sql stmt though it only returns the 1st image and it also displays the address where it is stored which i dont want. Any tips on how i get around this??
[code]
$sql ="select image, prodName ,price  from product where dept = 'mens'";

$imageDir = "http://snet.wit.ie/clothes/";
$imagePath = "$imageDir$image"

.....
<img src="<?php echo("$imagePath"); ?>"></font>[/code]
[/quote]


you have to concatenate the imagedir and $ image
like so
$imagePath = $imageDir."".$image;
and dont forget you semi colon like ya did above hope this helps

your image block should also be like this
<img src="<? echo $imagePath; ?>">

and that should do ya fine

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.