Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/47845-solved-not-sure-if/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/47845-solved-not-sure-if/#findComment-233788
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/47845-solved-not-sure-if/#findComment-233803
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.