Okay, my title may seem confusing but here is what I want:
I am trying to make it so that I can retrieve information, depending on which user is logged in. I have a page that when a user looks at it, the user see's his name. i have run into a problem, because I am unsure of how to retrieve more information from the database. I have this command
which will store their username within this session, and whenever I post
it will show their username.
But I also want to be able to show user-specific emails, contact information, gender, age, and other types of information. So I have two tables.
The first table details his registration info and has his ID (autoincrement), his first name, last name, password, and his email.
The second table details his ID (autoincrement), first name, last name, email, aboutme, location, etc. etc.
I'm not really sure how to link this information, so that if user (with ID 1) edits. . . let's say his location, how to make sure it goes into the ID column and not any other column.
I am also unsure how to pull this information out specific to a certain ID. So that if user (ID1) is looking at his home page, it shows just his information and not anyone elses. I also want it so that the email from table 1, automatically goes into table 2 if that is at all possible. . .
I'm not sure whether or not this is easy, but I have been unable to find the information for what I want on the internet, so I was wondering if anyone was willing to help or point me in the right direction for what I am looking for! If additional information is needed please ask! Thanks!
Well I figured out a temporary way, and repeated it several times so I would remember it. Here it is, please tell me if this isn't the most efficient way. . .
as of now, I have this repeated several times for each function. I am going to change "lastname" to the * so it takes all data, and then combine all the $db""=row['etc.']; but for now, I am happy.
Is this the best way? And should I also do this same function to store the info to my other table? As in use the "SELECT" and then put that info into the other table?
I am trying to make it so that I can retrieve information, depending on which user is logged in. I have a page that when a user looks at it, the user see's his name. i have run into a problem, because I am unsure of how to retrieve more information from the database. I have this command
PHP:
$_SESSION['username']=$dbusername;
which will store their username within this session, and whenever I post
PHP:
".$_SESSION['username']."
But I also want to be able to show user-specific emails, contact information, gender, age, and other types of information. So I have two tables.
The first table details his registration info and has his ID (autoincrement), his first name, last name, password, and his email.
The second table details his ID (autoincrement), first name, last name, email, aboutme, location, etc. etc.
I'm not really sure how to link this information, so that if user (with ID 1) edits. . . let's say his location, how to make sure it goes into the ID column and not any other column.
I am also unsure how to pull this information out specific to a certain ID. So that if user (ID1) is looking at his home page, it shows just his information and not anyone elses. I also want it so that the email from table 1, automatically goes into table 2 if that is at all possible. . .
I'm not sure whether or not this is easy, but I have been unable to find the information for what I want on the internet, so I was wondering if anyone was willing to help or point me in the right direction for what I am looking for! If additional information is needed please ask! Thanks!
Well I figured out a temporary way, and repeated it several times so I would remember it. Here it is, please tell me if this isn't the most efficient way. . .
PHP:
$getName = mysql_query("SELECT lastname FROM users WHERE username=".$_SESSION['username']."");
while ($row = mysql_fetch_assoc($getName)) //Checks their last name
{
$dbusername = $row['username'];
$dblastname= $row['lastname'];
}
as of now, I have this repeated several times for each function. I am going to change "lastname" to the * so it takes all data, and then combine all the $db""=row['etc.']; but for now, I am happy.
Is this the best way? And should I also do this same function to store the info to my other table? As in use the "SELECT" and then put that info into the other table?
Last edited: