Jump to content

[SOLVED] Elseif Statement


SkyRanger

Recommended Posts

I am not sure if it too early in the morning or what, but I am having a major brain fart..lol.  This is what I need, not sure if switch would work better though:

 

          
$allowaccess = "";
    if($access == "9") {
        $allowaccess = "  <a class=\"sidelink\" href=\"../office.php\">The Office</a><br>
<?=$officelink; ?>
<br>";
} elseif($access == "8") {
        $allowaccess = "  <a class=\"sidelink\" href=\"../office.php\">The Office</a><br>
<?=$officelink; ?>
<br>";
    } 
} elseif($access == "7") {
        $allowaccess = "  <a class=\"sidelink\" href=\"../office.php\">The Office</a><br>
<?=$officelink; ?>
<br>";
    } } elseif($access == "6") {
        $allowaccess = "  <a class=\"sidelink\" href=\"../office.php\">The Office</a><br>
<?=$officelink; ?>
<br>";
    } 
   ..etc
        echo $allowaccess;

 

Yeah, yeah i know <?= is not proper but it is old code.  Or is there an easier way than this?  like

 

if($access >="4") {

Link to comment
Share on other sites

If you only want access numbers 6 through to 9 to show a link to office.php just use a simple if statement:

// if access greater than or equal to 6 and is less than or equal to 9
// echo link to office.php
if($access >= 6 && $access <= 9)
{
    echo "  <a class=\"sidelink\" href=\"../office.php\">The Office</a><br>";
}

Link to comment
Share on other sites

If you only want access numbers 6 through to 9 to show a link to office.php just use a simple if statement:

// if access greater than or equal to 6 and is less than or equal to 9
// echo link to office.php
if($access >= 6 && $access <= 9)
{
    echo "  <a class=\"sidelink\" href=\"../office.php\">The Office</a><br>";
}

 

Thanks wildteen88, that worked exactly as I needed it.  I had that earlier but forgot to put && only had 1 & and couldn't figure out the problem..lol

Link to comment
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.