graham23s Posted May 4, 2007 Share Posted May 4, 2007 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 More sharing options...
taith Posted May 4, 2007 Share Posted May 4, 2007 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 More sharing options...
map200uk Posted May 4, 2007 Share Posted May 4, 2007 you want the if else to do what?! Link to comment https://forums.phpfreaks.com/topic/50021-ifelse-in-a-variable/#findComment-245588 Share on other sites More sharing options...
graham23s Posted May 4, 2007 Author Share Posted May 4, 2007 if photo exhists then display it, else displaly a generic photo. thanks mate i never thought about concatenating the variable cheets Graham Link to comment https://forums.phpfreaks.com/topic/50021-ifelse-in-a-variable/#findComment-245697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.