SkyRanger Posted April 22, 2007 Share Posted April 22, 2007 Not sure if doing this properly. $editbutton = $rowo2['login']; switch ($editbutton){ case $username: $linkbutton = "<a class=\"barlink\" href=\"officereplypostedit.php?oid=$oid\">Edit</a>"; break; default: $linkbutton = "Edit"; break; } echo $linkbutton; Ok, with the code above I am trying to: a) If the logged in $username = the posters username $rowo2['login']; They can edit the post with the link provided but if b) but if the $username does not = $rowo2['login']; then all they would get is a Edit without link. Link to comment https://forums.phpfreaks.com/topic/48169-solved-switch-problem/ Share on other sites More sharing options...
boo_lolly Posted April 22, 2007 Share Posted April 22, 2007 there's really no need to use a switch to replace an if/else. if($rowo2['login'] == $username){ echo "<a class=\"barlink\" href=\"officereplypostedit.php?oid={$oid}\">Edit</a>\n"; }else{ echo "Edit\n"; } wouldn't you agree? other than that your switch() looks fine. Link to comment https://forums.phpfreaks.com/topic/48169-solved-switch-problem/#findComment-235483 Share on other sites More sharing options...
SkyRanger Posted April 22, 2007 Author Share Posted April 22, 2007 Yeah I would agree. That would work 10x better, should have just used that instead. Thanks boo Link to comment https://forums.phpfreaks.com/topic/48169-solved-switch-problem/#findComment-235490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.