Jump to content

[SOLVED] Switch Problem


SkyRanger

Recommended Posts

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

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

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.