Results 1 to 3 of 3

Thread: URL contains string then...

  1. #1
    rlhanson's Avatar
    rlhanson is offline Master Glow Jedi
    Join Date
    Aug 2007
    Location
    Chapman, Kansas
    Posts
    531

    Default URL contains string then...

    I'm trying to figure out how to write a php statement ...

    here's a couple of url examples:

    /displayimage.php?album=1&pos=0
    /displayimage.php?album=1&pos=-1
    /displayimage.php?album=1&pos=-2

    What I want is if the "pos=0" is in the URL then I want to display:
    this
    If it's not, I want to display
    this other thing

    any suggestions?
    Thank you,
    Lynne Hanson
    RL Hanson-Online

  2. #2
    Dmitriy is offline Nearly a Master Glow Jedi
    Join Date
    Feb 2007
    Location
    Ukraine
    Posts
    124

    Default

    PHP Code:
    switch ($_GET['pos']) {
    case 
    '0':
    //do something for &pos=0
    break;

    case 
    '1':
    //do something for &pos=1
    break;

    .....

    default:
    echo 
    'Bad value for pos variable';
    break;


  3. #3
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default

    While D's structure is correct, you will of course need to use $_GET instead of $_POST if you are using an URL to pass data.

Similar Threads

  1. [How To] redirect a file to another url
    By Matt in forum Knowledge Base
    Replies: 2
    Last Post: 06-05-2007, 12:08 AM
  2. Add URL Request [removed]
    By abbacus in forum Web Design
    Replies: 0
    Last Post: 01-06-2006, 11:54 PM
  3. What is a URL?
    By Matt in forum Knowledge Base
    Replies: 0
    Last Post: 10-10-2005, 04:17 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16