SkyRanger Posted April 20, 2007 Share Posted April 20, 2007 Not sure exactly how to do this: $o1access = $rowo1["access"]; <-- Echo's proper output $boardlinks = ""; if ($o1access = 1) { echo "visitorlinks"; } elseif ($o1access = 2) { echo "payvisitorlinks"; } elseif ($o1access = 3) { echo "level 3 links"; } elseif ($o1access = 4) { echo "level 4 links"; } elseif ($o1access = 5) { echo "Full Admin Acess Links"; } echo $boardlinks; This part i cannot get working. Help Please Quote Link to comment https://forums.phpfreaks.com/topic/47845-solved-not-sure-if/ Share on other sites More sharing options...
Moon-Man.net Posted April 20, 2007 Share Posted April 20, 2007 one: you may want to look at this http://au.php.net/switch thats a lot better way of doing it than elseif all the time. And what are you trying to achieve? Im not sure I follow... -- Nathan Quote Link to comment https://forums.phpfreaks.com/topic/47845-solved-not-sure-if/#findComment-233783 Share on other sites More sharing options...
tauchai83 Posted April 20, 2007 Share Posted April 20, 2007 what are you trying to do? Do you mean each user will have different access level and access to different menu? Quote Link to comment https://forums.phpfreaks.com/topic/47845-solved-not-sure-if/#findComment-233785 Share on other sites More sharing options...
Fehnris Posted April 20, 2007 Share Posted April 20, 2007 The switch statement as Moon-Man.net stated is definately another possibly better way to go than the if/elseif. Your code says at the bottom "this part I cannot get working". In what way does it not work? Does it give error messages or does it produce something different than you want? Quote Link to comment https://forums.phpfreaks.com/topic/47845-solved-not-sure-if/#findComment-233788 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 20, 2007 Share Posted April 20, 2007 Three things, access is spelled wrong under level five, doing if($o1access = 1) is setting the value of $o1access to 1, so basically, you are setting it to one, then two, then three, then four, then five, you need double ='s, like this if($o1access == 1), and finally, you are never setting $boardlinks to anything other than "", so echoing $boardlinks will still give you nothing, I think what you want to try is this: $o1access = $rowo1["access"]; switch ($o1access) { case 1: $boardlinks = "visitorlinks"; break; case 2: $boardlinks = "payvisitorlinks"; break; case 3: $boardlinks = "level 3 links"; break; case 4: $boardlinks = "level 4 links"; break; case 5: $boardlinks = "Full Admin Acess Links"; break; } echo $boardlinks; Try that out and see what you get. Quote Link to comment https://forums.phpfreaks.com/topic/47845-solved-not-sure-if/#findComment-233803 Share on other sites More sharing options...
SkyRanger Posted April 20, 2007 Author Share Posted April 20, 2007 Awesome, works now, thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/47845-solved-not-sure-if/#findComment-233891 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.