Getting user_id using information from another column
Posted: Mon Oct 22, 2012 11:21 am
Hey guys,
I've been sitting her for hours trying to figure this out. I've Google'd like crazy as well but can't find an answer to my problem and that is that I can't get the information from another column using information from another column. This is how my table is set up.
(Ignore the - as they are to fill in spaces.
Table name: users
user_id | user_email --------|user_pass
-----1----|--false@fake.com--|-------fake--------
Now, I get the email from the session and I want to get the user_id from the email. Here is what I have right now but I just can't get it to work.
(Please note that $email is defined as below and the session is working correctly as I can output the email.)
I've been sitting her for hours trying to figure this out. I've Google'd like crazy as well but can't find an answer to my problem and that is that I can't get the information from another column using information from another column. This is how my table is set up.
(Ignore the - as they are to fill in spaces.
Table name: users
user_id | user_email --------|user_pass
-----1----|--false@fake.com--|-------fake--------
Now, I get the email from the session and I want to get the user_id from the email. Here is what I have right now but I just can't get it to work.
(Please note that $email is defined as below and the session is working correctly as I can output the email.)
$email = $_SESSION['user_email'];
$res = mysql_query("SELECT `user_id` FROM `users` WHERE '{$email}' = `user_id`"); $user = mysql_fetch_assoc($res); echo $user;All help would be greatly appreciated!