Jump to content

if/else in a variable


graham23s

Recommended Posts

Hi Guys,

 

i have this variable called: $profiles

 

here:

 

     $profiles = "<br /><table border=\"1\" bordercolor=\"black\" cellpadding=\"4\" cellspacing=\"0\" width=\"300\" height=\"80\">
                       <tr>
                   <td background=\"images/background.jpg\" align=\"center\">
                   <img src='uploads/$photo1' width=\"100\" height=\"118\" alt=\"$username\"></td>                   		                 	                   	                 
                   <tr>
                   <td bgcolor=\"#E2E2E2\" align=\"center\"><a href=\"profile.php?id=$id\"><p>$username</a> From <b><font color=\"red\">$country</font></b></td>
                       </tr></table><br />";

 

the only thing is i want to put an if/else statement in but don't know how to go about it and help would be appreciated

 

heres the if/else

 

 

 

	                   if($photo == 0) {  
                      
                           echo "<img src='uploads/no_pic.jpg' />";  
                               
                         } else {    
                          
                           echo "<img src='uploads/$photo1' border='0' />"; 
                         }

 

thanks

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/50021-ifelse-in-a-variable/
Share on other sites

assuming this is what you mean...

 

$profiles="<br /><table border=\"1\" bordercolor=\"black\" cellpadding=\"4\" cellspacing=\"0\" width=\"300\" height=\"80\">";
$profiles.=" <tr>";
$profiles.="  <td background=\"images/background.jpg\" align=\"center\">";
if($photo == 0){
$profiles.="<img src='uploads/no_pic.jpg' />";
}else{
$profiles.="<img src='uploads/$photo1' border='0' />";
}
$profiles.="  </td>";
$profiles.=" <tr>";
$profiles.="  <td bgcolor=\"#E2E2E2\" align=\"center\"><a href=\"profile.php?id=$id\"><p>$username</a> From <b><font color=\"red\">$country</font></b></td>";
$profiles.=" </tr>";
$profiles.="</table><br />";

Link to comment
https://forums.phpfreaks.com/topic/50021-ifelse-in-a-variable/#findComment-245585
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.