Jump to content


Photo

Pulling images from DB


  • Please log in to reply
2 replies to this topic

#1 w00kie

w00kie
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 24 April 2006 - 10:27 AM

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?

#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 24 April 2006 - 10:53 AM

does it just not display the image, or does it display the X image not exist icon?

ie, is it that your if/else doesnt work, or that there is an error in your code within the if/else
wisewood: proven fact, I am both wise, and wooden.

#3 freakus_maximus

freakus_maximus
  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 24 April 2006 - 01:06 PM

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:

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

If that doesnt help let us know...






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users