Results 1 to 2 of 2

Thread: pulling information according to id

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    95

    pulling information according to id

    I'm trying to make it where the id number is a link that you can click on,
    and when you click on it, it will pull fields according to the id you clicked on, is this possible from log, to say "account.php" (account.php will see the id you clicked from the link, and will return it's field data that i want to show)

    Example:
    Memberlist.php:
    (Note the ID # (aka 1) will be a link you can click on and will goto profile.php,
    and show all its called field info)
    1 - User1
    2 - User2
    3 - User3

    Profile.php:
    User1's Profile
    Email: [email protected]
    Name: Test


    ....
    ....
    I also have AIM: Lukeidiots
    MSN: [email protected] you can contact me there.
    Visual Basic 6 + MS Access

  2. #2
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: pulling information according to id

    Have a look at some PHP+MySQL tutorials (assuming you're using MySQL).

    What is your database structure? Have you got all the user information in one table, or is it normalised into seperate tables?

    Basically on the page with the list of members you need to run a SQL query to get the ID and user name for the list, then just loop through the result set creating the link.

    PHP Code:
    $sql "SELECT id, name FROM users";

    //loop through result and create the links 
    Then on the profile page, you can pickup the ID requested by using the querystring in the URL, the link would be profile.php?id=X

    PHP Code:
    $user_id mysql_real_escape_string($_GET['id']); //get the ID from the querystring
    $sql "SELECT name, email, phone FROM users WHERE id = '$user_id'"

    //get result of query 
    Chris

Posting Permissions

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



Click Here to Expand Forum to Full Width