pandaweb Posted December 11, 2009 Share Posted December 11, 2009 so i have a database table called users which is setup as follows id full_name user_pwd user_email date_joined ip port client and id like to echo "ip" "port" and "client" for the user that is logged in. i have the following code but it only displays database entries from the first row of the table and not the logged in user. here is my fetch code <?php include 'dbc.php'; $query = "SELECT ip,port,client,joined FROM users"; $result = mysql_query($query); $row = mysql_fetch_array($result, MYSQL_ASSOC); echo "Torrent Client:<font color='red'> {$row['client']} </font><br>" . "IP:Port:<font color='red'> {$row['ip']}:{$row['port']} </font><br>" . "Member Since:<font color='red'> {$row['joined']} </font>"; ?> thanks in advanced Link to comment https://forums.phpfreaks.com/topic/184747-echo-database-entry/ Share on other sites More sharing options...
Zyx Posted December 11, 2009 Share Posted December 11, 2009 Because you haven't told it you want the data of the logged user. Where the database should know that from? $result = mysql_query('SELECT ip,port,client,joined FROM users WHERE `id` = \''.$loggedUserId.'\''); Link to comment https://forums.phpfreaks.com/topic/184747-echo-database-entry/#findComment-975283 Share on other sites More sharing options...
pandaweb Posted December 11, 2009 Author Share Posted December 11, 2009 i knew i had to tell it what user to look it, i just didnt know how. thanks for that answer heres the code i ended up with to work for me $result = mysql_query('SELECT ip,port,client,joined FROM users WHERE `user_email` = \''.$_SESSION[user].'\''); Link to comment https://forums.phpfreaks.com/topic/184747-echo-database-entry/#findComment-975288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.