PDA

View Full Version : Trouble when getting information from two tables


Trusten
08-21-2002, 06:51 AM
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?!

Ökii
08-21-2002, 01:34 PM
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'");

Trusten
08-21-2002, 04:10 PM
Thank you for the response. Kinda tried that, didn't work.

$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??