newbie here

Discussion in 'PHP' started by gigamike, Oct 13, 2006.

  1. #1
    Hi Guys,

    im mikeg from philippines :). Guys i hope you can give me an idea, actually this is easy though im new to php. How i can read this value or parameter in URL

    example: www.domain.com/test.php?12

    i need to get the value 12 but how? is parsing from right to left is the only option and when i encounter the ? thats the value i need...is there another way?

    Thanks a lot,

    mikeg
     
    gigamike, Oct 13, 2006 IP
  2. ThomasNederman

    ThomasNederman Peon

    Messages:
    112
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    echo $_SERVER["QUERY_STRING"]; should do it

    good luck
     
    ThomasNederman, Oct 13, 2006 IP
  3. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Use isset($_GET['12']). It will be set, but with a null value.
     
    penagate, Oct 13, 2006 IP
  4. ThomasNederman

    ThomasNederman Peon

    Messages:
    112
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    if you use isset() you will have to make a loop if it can be more values like

    while $i < 1000000){

    if (isset($_GET[$i])){

    $value = $i;
    }
    $i++
    }

    (the above is a waste of resources on the server)Or easyer why not
    www.domain.com/test.php?ID=12
    then you can read $_GET['ID'];
     
    ThomasNederman, Oct 13, 2006 IP
  5. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Well, it solved the problem that was presented. Not enough info to give a better solution without making assumptions.
     
    penagate, Oct 13, 2006 IP
  6. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #6
    hi guys,

    first of all i like to thankyou all for the quick response. Actually i agree to thomas to use this method:

    www.domain.com/test.php?referrer=12

    unfortunately the client request this method

    www.domain.com/test.php?12

    I'll try now you suggestions.

    Thanks again,

    mikeg
     
    gigamike, Oct 13, 2006 IP
  7. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I would explain to your client that its impossible and suggest a better way.
     
    mad4, Oct 13, 2006 IP
  8. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #8
    hi,

    this works for me $_SERVER["QUERY_STRING"];

    thanks again,

    mikeg
     
    gigamike, Oct 13, 2006 IP
  9. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #9
    If you read the suggestions above you'll see it's perfectly possible.
     
    penagate, Oct 13, 2006 IP