Jump to content

Show different image if row empty


craigeves

Recommended Posts

Hi

 

Please help.

 

I want to be able to show a standard photo if the row 'photo' in my database is empty.

 

This script will show the uploaded photo if the row isn't empty but for some reason wont show the standard photo if the row is empty.

 

Can anyone help?

 

Thanks

 

 <?php 
$sitephoto = $row_getUsers['photo'];

if (empty($row_getUsers['photo'])) { 
   $row_getUsers['photo'] = '<img src="../sites/images/uploadaphoto.gif" width="200" height="128" />'; 
} 
echo '<img src="../sites/images/profiles/'.$sitephoto.'" title="Photo" alt="Photo" />'; 
?>

Link to comment
https://forums.phpfreaks.com/topic/194227-show-different-image-if-row-empty/
Share on other sites

I think i just answered my own question...

 <?php 
$sitephoto = $row_getUsers['photo'];

if (empty($row_getUsers['photo'])) { 
   echo '<img src="../sites/images/uploadaphoto.gif" width="200" height="128" />'; 
} 
else echo '<img src="../sites/images/profiles/'.$sitephoto.'" title="Photo" alt="Photo" />'; 
?>

 

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.