Matt01 Posted September 15, 2008 Share Posted September 15, 2008 I am new to this sql / php thing and need some help on a query. I got a database with a bunch of values in, ID, Username, Email, Password, IP,... and so on. I need some simple script that will display the email address on the webpage of the user logged on. Im not sure howto do this and cant seem to find any examples on the net. Can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/124346-sql-query-php-display-email/ Share on other sites More sharing options...
fenway Posted September 15, 2008 Share Posted September 15, 2008 Im not sure howto do this and cant seem to find any examples on the net. Seriously? Quote Link to comment https://forums.phpfreaks.com/topic/124346-sql-query-php-display-email/#findComment-642152 Share on other sites More sharing options...
Maq Posted September 15, 2008 Share Posted September 15, 2008 Can anyone help? Sure. Grab the session id and match it with the id in the table then display the email. Quote Link to comment https://forums.phpfreaks.com/topic/124346-sql-query-php-display-email/#findComment-642178 Share on other sites More sharing options...
Matt01 Posted September 15, 2008 Author Share Posted September 15, 2008 Got an example maq? I just want an example to display an email address from a field linking the ID to whos logged on ID Username Password Email IP 1 Matt Let Me In Matt@needshelp.com 127.0.01 2 Maq Help Me Maq@helpmeplz.com XXX.XXX.XXX.XXX Just a simple script to display the value of the email address depending whos logged on I learn from examples, if I cant find an example then i cant really learn anything. Quote Link to comment https://forums.phpfreaks.com/topic/124346-sql-query-php-display-email/#findComment-642226 Share on other sites More sharing options...
Maq Posted September 15, 2008 Share Posted September 15, 2008 First of all, do you have sessions setup? Quote Link to comment https://forums.phpfreaks.com/topic/124346-sql-query-php-display-email/#findComment-642238 Share on other sites More sharing options...
Matt01 Posted September 15, 2008 Author Share Posted September 15, 2008 yeah i got sessions on. <?php session_start(); if($_SESSION['s_logged_n'] == 'true'){ include 'config.php'; include 'process.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/124346-sql-query-php-display-email/#findComment-642241 Share on other sites More sharing options...
Matt01 Posted September 16, 2008 Author Share Posted September 16, 2008 I found this script on the net, it works but it displays all the email address' in the field Email because ID isnt included in the code. $result = mysql_query("SELECT * FROM Users"); while($row = mysql_fetch_array($result)) { echo "" . $row['Email'] . ""; } I need to somehow include a ID so it only displays the email address of the user logged on and not all the email address'. Can someone help me please, I know your prob thinking amg what a n00b but really this script is doing my head in. I know theres someone out there who can do this in like 10secs so please post since im getting really annoyed with server errors!!! I tried to change the code to add ID but im still prob not doing the right thing. <?php $id = $_GET['id']; $result = mysql_query("SELECT * FROM Users WHERE Email = '$id' LIMIT 1"); while($row = mysql_fetch_array($result)) { echo "" . $row['Email'] . ""; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/124346-sql-query-php-display-email/#findComment-643240 Share on other sites More sharing options...
Maq Posted September 17, 2008 Share Posted September 17, 2008 Of course this: $id = $_GET['id']; isn't going to work... Why would you compare an id to an email? You need to assign a session ID and compare that with the ID's in your DB. I'm sure there's plenty of tutorials for this but here's what your query portion would look like: $id = $_SESSION['id']; $result = mysql_query("SELECT * FROM Users WHERE Email = " . $id . ""); while($row = mysql_fetch_array($result)) { echo $row['Email']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/124346-sql-query-php-display-email/#findComment-643723 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.