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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Earth
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble when getting information from two tables

    I have two tables. One for member info, and one for their profile.

    Now, I had some help making that script so whenever the person signs up, automatically, the same info is sent to the profile table and the member table.

    what matches between them is their user id.

    well, on the members table, it's called id (that number)
    and on the profile table is id, and userID.

    the id from the members table and the userID from the profiles table match.

    now when i'm trying to get the info back, such as any profile info for someone from the members table, I don't know how to talk to the database so that it gives me the right info for the right person.

    mysql_query($query);

    $userid = mysql_insert_id();

    that's what helped me add them to both tables,

    how do i select from the table.

    technically,

    profile.userID = members.id

    any help please?!
    Life is funny, especially when you're poor.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If the value of id is accessible within the script - eg page.php?id=77, you would just use a WHERE clause in the SELECT statement.

    $query = mysql_query("SELECT * FROM `profiles` WHERE userID='$id'");
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Earth
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for the response. Kinda tried that, didn't work.

    PHP Code:
    $resultID mysql_query("SELECT email FROM profile WHERE userID = '$id'"$linkID) or die(mysql_error());
            while (list(
    $email) = mysql_fetch_row($resultID))

    {
                print 
    "$email";
            } 
    and no go. all it does is show me those profile entries that do not have any userID to them. That is all it does.

    why??
    Life is funny, especially when you're poor.


  •  

    Posting Permissions

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