Jump to content

[SOLVED] Not sure if


SkyRanger

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

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.