Need Help - How do I make a page.php?id=#

Discussion in 'PHP' started by P5Solutions, Aug 1, 2008.

  1. #1
    Hello everyone.

    I am looking at making a page like this link, but I'm not sure how to.

    It is somehow taking the user name from the database, and automatically generating the page content from that.

    Any help is greatly appreciated!
     
    P5Solutions, Aug 1, 2008 IP
  2. Pos1tron

    Pos1tron Peon

    Messages:
    95
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you mean how do you access that #, you use $_GET['element name here']. Replace element name by what's put as 'id' in this case, and the value of $_GET['id'] in the case will be whatever # you enter.
    See w3schools.com/PHP/php_get.asp to learn properly about it.
     
    Pos1tron, Aug 1, 2008 IP
  3. P5Solutions

    P5Solutions Active Member

    Messages:
    342
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Okay, that helps :)

    However, how do I use it to get the data from a mysql database?
     
    P5Solutions, Aug 1, 2008 IP
  4. Pos1tron

    Pos1tron Peon

    Messages:
    95
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You're probably best reading through some online tutorials.

    php-mysql-tutorial.com <--- possibly not the best site, but it does what it says on the tin.
    tizag.com/mysqlTutorial/ <--- another one to take a look at
     
    Pos1tron, Aug 1, 2008 IP
  5. CarcaBot

    CarcaBot Active Member

    Messages:
    389
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #5
    This Shold help u !
    to tests just replace "table" and "name " with ur values !
    <?
    include('config.php');
    if(isset($_GET[id])) {
    $name = $_GET[id];
    // query
    $query = mysql_query("SELECT * from table where name='$name'");
    if(mysql_num_rows($query) == '0') {
    echo "Thers no user with that name";
    } else {
    $row = mysql_fetch_array($query);
    echo "Name = $row[name]";
    }
    
    
    
    
    }
    
    ?>
    
    PHP:
    if u need help pm or email me !
     
    CarcaBot, Aug 1, 2008 IP
  6. P5Solutions

    P5Solutions Active Member

    Messages:
    342
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #6
    I got it working - thanks everyone!
     
    P5Solutions, Aug 1, 2008 IP