Using "Show if..." condition (php) with images

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Nineve
Forum Newbie
Posts: 1
Joined: Fri May 23, 2008 3:18 pm

Using "Show if..." condition (php) with images

Post by Nineve »

I'm using dreamweaver to create dynamic web pages.
The following;

<?php if ($totalRows_DetailRS1 > 0) { // Show if recordset not empty ?>
<img src="eventImages/sponsor/<?php echo $row_DetailRS1['event_sponsor_img2']; ?>" alt="<?php echo $row_DetailRS1['event_sponsor_img2']; ?>" id="smpictures" />
<?php } // Show if recordset not empty ?>

results in a ? marked box (no picture found) when the database does not have an image for that event. How do I make it so nothing shows if nothing is in the database for that event?

And why would this not work? (It doesn't)

<?php
if ( $row_rsDetailRS1['event_sponsor_img2'] == NULL) {
echo "";
}
else {
echo "<img src="eventImages/sponsor/<?php echo $row_DetailRS1['event_sponsor_img2']; ?>" alt="<?php echo $row_DetailRS1['event_sponsor_img2']; ?>" id="smpictures" />";
}
?>



Thank you in advance for any help. :)
whiterabbit
Forum Newbie
Posts: 14
Joined: Thu May 22, 2008 6:58 pm

Re: Using "Show if..." condition (php) with images

Post by whiterabbit »

Try:

Code: Select all

 
if ( $row_rsDetailRS1['event_sponsor_img2'] == "") 
{
   echo "";
}
 
Post Reply