Jump to content

Pulling images from DB


w00kie

Recommended Posts

I have a database with 10 thumbnail pictures, image1, image2, image3 and so fourth

when i add a picture, i add the - 'event_images/image1.jpg' for instance which is fine.

But, what i need help with is, if the cell for image1, is empty, it doesnt contain a path then to dispaly a Blank image. Such as 'event_images/spacer.jpg'


thanks for your help in advanced.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]if ($image_1 == "") {

echo "<a href=event_images/blank.jpg><img name=eventimage src=event_images/blank.jpg width=40 height=40 border=2
></a> ";

} else {

echo "<a href=event_images/$image_1><img name=eventimage src=event_images/$image_1 width=40 height=40 border=2
></a> ";
}[/quote]

Thats what i was thinkinjg, would there be an easier way?
Link to comment
https://forums.phpfreaks.com/topic/8244-pulling-images-from-db/
Share on other sites

If this what you are adding to the db:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]when i add a picture, i add the - 'event_images/image1.jpg' for instance which is fine. [/quote]

And this is what you are using to retrieve:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]src=event_images/$image_1 [/quote]

Then your src path is actually "event_images/event_images/image1.jpg". Which, unless you have your folders structred that way, would not be correct.

Also, I think this:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]echo "echo "<a href=event_images/$image_1><img name=eventimage src=event_images/$image_1 width=40 height=40 border=2
></a> ";[/quote]

Should be:

[code]echo ('<a href=event_images/$image_1><img name=eventimage src=event_images/'.$image_1.' width=40 height=40 border=2
></a>');[/code]

If that doesnt help let us know...

Link to comment
https://forums.phpfreaks.com/topic/8244-pulling-images-from-db/#findComment-30080
Share on other sites

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.