unkwntech Posted August 29, 2008 Share Posted August 29, 2008 Its been a while since I've done it or seen it for that matter and I cant seem to come up with the correct syntax, what I need is a condition inside a variable assignment something like this: $page['text']='<table width="100%" border="0" cellpadding="2">' . "\n<tr> <td width=\"7%\"><a href=\"&s=" . if($sort==0){echo 1;}else{echo 0;} . "\">ID</a></td> <td width=\"19%\"><a href=\"&s=" . if($sort==2){echo 3;}else{echo 2;} . "\">Name</td> Link to comment https://forums.phpfreaks.com/topic/121901-solved-conditions-inside-variables/ Share on other sites More sharing options...
wildteen88 Posted August 29, 2008 Share Posted August 29, 2008 use a ternary operator $page['text']='<table width="100%" border="0" cellpadding="2">' . "\n<tr> <td width=\"7%\"><a href=\"&s=" . (($sort==0) ? 1 : 0 ). "\">ID</a></td> <td width=\"19%\"><a href=\"&s=" . (($sort==2) ? 3 : 2 ) . "\">Name</td> Link to comment https://forums.phpfreaks.com/topic/121901-solved-conditions-inside-variables/#findComment-628975 Share on other sites More sharing options...
unkwntech Posted August 29, 2008 Author Share Posted August 29, 2008 Thats it, Thanks. Link to comment https://forums.phpfreaks.com/topic/121901-solved-conditions-inside-variables/#findComment-628978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.