Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    useing switch statement

    I am very new to php and was wondering how do I get the users addressbar info into the switch statement

    see below where $x is http://www.site.com?name=$x so if I had Http://www.site.com?name=1 then case 1 would run
    PHP Code:
    <?php
    switch ($x)
    {
    case 
    1:
      echo 
    "Number 1";
      break;
    case 
    2:
      echo 
    "Number 2";
      break;
    case 
    3:
      echo 
    "Number 3";
      break;
    default:
      echo 
    "No number between 1 and 3";
    }
    ?>

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i suppose yu're looking for
    PHP Code:
    <?php
    switch ($_GET['name']){
      case 
    1:
        echo 
    "Number 1";
        break;
      case 
    2:
        echo 
    "Number 2";
        break;
      case 
    3:
        echo 
    "Number 3";
        break;
      default:
        echo 
    "No number between 1 and 3";
    }
    ?>
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •