brainstorm Posted June 24, 2009 Share Posted June 24, 2009 Hi All, I have a page called "myaccount.php" where I want a client to go and only see their information. right now, the page displays all client rows and I can't seem to figure out how to sort by the data by current user...Any help is greatly appreciated! This is what I have so far... Thanks! Session verify: <?php session_start(); if (!isset($_SESSION['user'])) { die ("Access Denied"); } ?> Display table; <?php include 'dbc.php'; $data = mysql_query("SELECT * FROM users order by full_name where user_email LIKE ".$_SESSION['user']."") or die(mysql_error()); Print "<table border=1 cellpadding=2 cellspacing=0 width=100%> <tr> <td valign=top align=left><strong>Name</strong></td> <td valign=top align=left><strong>Address</strong></td> <td valign=top align=left><strong>Joined</strong></td> <td valign=top align=left><strong>Email</strong></td> </tr>"; while($info = mysql_fetch_array( $data )) { Print "<tr>"; Print "<td bgcolor=#accbed>".$info['full_name'] . "</td> "; Print "<td>".$info['address'] . "</td> "; Print "<td>".$info['joined'] . "</td> "; Print "<td>".$info['user_email'] . "</td></tr> "; } Print "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/163494-solved-displaying-data-based-on-current-user-id-need-help/ Share on other sites More sharing options...
KevinM1 Posted June 24, 2009 Share Posted June 24, 2009 Try modifying your query to something like: "SELECT * FROM users WHERE user_email = {$_SESSION['user']} ORDER BY full_name" Quote Link to comment https://forums.phpfreaks.com/topic/163494-solved-displaying-data-based-on-current-user-id-need-help/#findComment-862653 Share on other sites More sharing options...
brainstorm Posted June 24, 2009 Author Share Posted June 24, 2009 Try modifying your query to something like: "SELECT * FROM users WHERE user_email = {$_SESSION['user']} ORDER BY full_name" I just tried it and I got the following error within the page. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@earthlink.net ORDER BY full_name' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/163494-solved-displaying-data-based-on-current-user-id-need-help/#findComment-862657 Share on other sites More sharing options...
947740 Posted June 24, 2009 Share Posted June 24, 2009 Maybe try "SELECT * FROM users WHERE user_email = '{$_SESSION['user']}' ORDER BY full_name" OR "SELECT * FROM users WHERE user_email = \"{$_SESSION['user']}\" ORDER BY full_name" Quote Link to comment https://forums.phpfreaks.com/topic/163494-solved-displaying-data-based-on-current-user-id-need-help/#findComment-862660 Share on other sites More sharing options...
KevinM1 Posted June 24, 2009 Share Posted June 24, 2009 Hmm...I'm not sure where the syntax error would be. Going by the documentation, it looks right: http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html Quote Link to comment https://forums.phpfreaks.com/topic/163494-solved-displaying-data-based-on-current-user-id-need-help/#findComment-862661 Share on other sites More sharing options...
brainstorm Posted June 24, 2009 Author Share Posted June 24, 2009 Maybe try "SELECT * FROM users WHERE user_email = '{$_SESSION['user']}' ORDER BY full_name" OR "SELECT * FROM users WHERE user_email = \"{$_SESSION['user']}\" ORDER BY full_name" The second line worked!!!! I'm all set guys! Thank you so much for your help!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/163494-solved-displaying-data-based-on-current-user-id-need-help/#findComment-862711 Share on other sites More sharing options...
947740 Posted June 24, 2009 Share Posted June 24, 2009 If you could hit the "topic solved" button in the lower-left hand corner, that would be great. Quote Link to comment https://forums.phpfreaks.com/topic/163494-solved-displaying-data-based-on-current-user-id-need-help/#findComment-862713 Share on other sites More sharing options...
brainstorm Posted June 24, 2009 Author Share Posted June 24, 2009 If you could hit the "topic solved" button in the lower-left hand corner, that would be great. Done! Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/163494-solved-displaying-data-based-on-current-user-id-need-help/#findComment-862755 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.