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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.