SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: Question!

  1. #1
    SitePoint Evangelist Raining_Curses's Avatar
    Join Date
    May 2005
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question!

    I see sometimes in website addresses, something like, page.php?something=somethingelse.

    What does it mean, I know that it is in someway linked to getting data from a database.

    Thanks

    Raining
    www.thetrial.staronesw.com
    Check out my online text based rpg (In development!!)

  2. #2
    SitePoint Evangelist Rodney H.'s Avatar
    Join Date
    Sep 2005
    Location
    Chicago, IL
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It means that a value is getting passed from one page to the next via the query-string using the $_GET global array.

    The key is: page.php?something=somethingelse

    And the value is: page.php?something=somethingelse

    (It is not just for database use.)

    To access that value on "page.php", you would do something like this:

    PHP Code:
    <?php
    if(isset($_GET['something'])){
         
    $something $_GET['something'];
    }
    ?>
    Now you can access that value via the variable, $something.

    Check the manual here for more info: http://us3.php.net/manual/en/reserve....variables.get

  3. #3
    SitePoint Evangelist nsj's Avatar
    Join Date
    Oct 2005
    Location
    Jamaica (W.I)
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It may or may not have something to do with a database.
    It just means that you're passing a variable of "something" with a value of "somethingelse" to page "page.php".

    In page.php, if you say:
    $value = $_GET['something'];
    print $value;

    it prints somethingelse.

    This is a way of passing form values or any other values from one page to another.

    Another way of doing this is post. You might want to do some reading up on $_GET and $_POST variables.

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    it is basically using a variable in the url to tell the script which variables are to be used for the script.

    So for example a url like
    page.php?id=2&data=testdata

    you would use $_GET to 'get' the variables from the url....
    PHP Code:
    $id $_GET['id]; #this would set the variable id to the value 2
    $data = $_GET['
    data']; # this would give the variable $data to the value of testdata 

    Hope that makes sense!

    Cheers

    Spike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Evangelist Raining_Curses's Avatar
    Join Date
    May 2005
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok so what does it mean if it says, page.php?p=something.somethingdifferent?

    Reagrds,

    Raining
    www.thetrial.staronesw.com
    Check out my online text based rpg (In development!!)

  6. #6
    SitePoint Member guitarman's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raining_Curses
    Ok so what does it mean if it says, page.php?p=something.somethingdifferent?
    Is there such thing as something.somethingelse ???

  7. #7
    SitePoint Evangelist Rodney H.'s Avatar
    Join Date
    Sep 2005
    Location
    Chicago, IL
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, your example literally means: 'p' being passed in the q-string with the value 'something.somethingdifferent'

    Here is another example: http://www.domain.com/index.php?user=raining&status=2

    Here, two values are getting passed in the query string and can be accessed via the $_GET super global array.

    $_GET['user'] has the value of 'raining'

    AND

    $_GET['status'] has the value of '2'

  8. #8
    SitePoint Evangelist Raining_Curses's Avatar
    Join Date
    May 2005
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks, i was just curious thanks.

    Raining
    www.thetrial.staronesw.com
    Check out my online text based rpg (In development!!)

  9. #9
    SitePoint Evangelist Raining_Curses's Avatar
    Join Date
    May 2005
    Posts
    560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Rodney H.
    Well, your example literally means: 'p' being passed in the q-string with the value 'something.somethingdifferent'

    Here is another example: http://www.domain.com/index.php?user=raining&status=2

    Here, two values are getting passed in the query string and can be accessed via the $_GET super global array.

    $_GET['user'] has the value of 'raining'

    AND

    $_GET['status'] has the value of '2'
    So is doing http://www.domain.com/index.php?user=raining&status=2,

    the same as doing,

    http://www.domain.com/index.php?user=raining.status=2

    Could i still use $get['user']; and $get['status']; to get the two seperate parts?
    www.thetrial.staronesw.com
    Check out my online text based rpg (In development!!)

  10. #10
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raining_Curses
    So is doing http://www.domain.com/index.php?user=raining&status=2,

    the same as doing,

    http://www.domain.com/index.php?user=raining.status=2

    Could i still use $get['user']; and $get['status']; to get the two seperate parts?
    Not unless you've set the dot to be your argument separator on the server. The default is to use a question mark as the separator between the path and the arguments, and to have an ampersand as the separator between multiple arguments.
    Birnam wood is come to Dunsinane


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
  •