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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts

    Page ID's - $_GET

    Hello,

    I'm trying to figure out how to make a page URL like www.example.com/index.php?page=username

    With some help of another guy, I've come up with this.

    PHP Code:
    $nick "test";

    $query "SELECT * FROM members WHERE user_name = '$nick'";
    $result mysql_query($query,$db);

    $row mysql_fetch_array($result);

    $userid $row['user_id']; 
    Then he showed me for the link, I'd use something like this:
    PHP Code:
    echo "<a href=\"index.php?page=$userid\">Asdissimo</a>"
    Now the part that really confuses me is that when I press the link, he told me this comes into play
    PHP Code:
    if(isset($_GET['page'])) {

    your code here


    I have no idea where the $_GET['page' comes from, or how to use it.

    Can someone possibly help?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    That Stuff after the "?" in the URL is called a query string. Google "query string" +tutorial +php

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hello...

    $_GET is An associative array of variables passed to the current script via the HTTP GET method.

    if you want to know.....
    copy and paste this code to "index.php" file and save it
    PHP Code:
    echo "<a href=\"index.php?page=Asdissimo\">Asdissimo</a> <br>";  
    echo 
    "<a href=\"index.php?page=Angel\">Angel</a> <br>";
    echo 
    "<a href=\"index.php?page=fl00d\">fl00d</a> <br>";


    if(isset(
    $_GET['page'])) {
    echo 
    "Hello , "
    echo 
    $_GET['page']; 

    if you click first link ... the result will be "Hello , Asdissimo"
    if you click second link ... the result will be "Hello , Angel"
    .. and so on.....

    you can test with more variable... to see the different.

    PHP Code:
    echo "<a href=\"index.php?page=Asdissimo&age=17\">Asdissimo</a> <br>";  
    echo 
    "<a href=\"index.php?page=Angel&age=14\">Angel</a> <br>";
    echo 
    "<a href=\"index.php?page=there&age=70\">there</a> <br>";


    if(isset(
    $_GET['page'])) {
    echo 
    "Hello , "
    echo 
    $_GET['page']; 
    echo 
    "<br> You are ";
    echo 
    $_GET['age'];
    echo 
    " years old.";


    hope this usefull

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts
    ok yes i see now. thanks. what I was getting confused about wsa the ['page'] part of the $_GET associative array. i couldnt figure out where it was getting defined but now i see. 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
    •