rastaman46 Posted March 28, 2012 Share Posted March 28, 2012 Hello im just beginner on this side. Here what im trying to do but not successful SELECT m.memberid, p.memberid, p.uploaded, p.downloaded, p.total_posts, p.invites_left, p.points FROM tsue_members m, tsue_member_profile p WHERE p.memberid=m.memberid query work but i want to get memberid diferent for every member Say im logged im see my stats user logged hes see hes stats. Thanks Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/ Share on other sites More sharing options...
AyKay47 Posted March 28, 2012 Share Posted March 28, 2012 well, what are the actual results? Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331863 Share on other sites More sharing options...
rastaman46 Posted March 28, 2012 Author Share Posted March 28, 2012 here result of this query memberid memberid uploaded downloaded total_posts invites_left points 2 2 1073741824 0 3 1 25 3 3 1073741824 0 0 1 10 4 4 1073741824 0 0 1 10 5 5 1073741824 0 0 1 10 6 6 1073741824 0 0 1 10 7 7 1073741824 0 0 1 10 8 8 1073741824 0 0 1 10 9 9 1073741824 0 0 1 10 10 10 1073741824 0 0 1 13 11 11 1073741824 0 1 1 18 12 12 1073741824 0 0 1 16 13 13 1073741824 0 0 1 10 14 14 1073741824 0 0 1 10 15 15 1073741824 0 0 1 10 16 16 1073741824 0 0 1 10 17 17 1073741824 0 0 1 10 18 18 1073741824 0 0 1 10 19 19 1073741824 0 0 1 10 1 1 50000 10000 6 10 1133 20 20 0 0 0 0 3 Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331865 Share on other sites More sharing options...
seanlim Posted March 28, 2012 Share Posted March 28, 2012 You will have to tie your MySQL query to your PHP code, i.e. insert the currently-logged-in user's id into the MySQL query: SELECT m.memberid, p.memberid, p.uploaded, p.downloaded, p.total_posts, p.invites_left, p.points FROM tsue_members m, tsue_member_profile p WHERE p.memberid=m.memberid AND p.memberid="3"; where the 3 is the user id of the user. Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331866 Share on other sites More sharing options...
rastaman46 Posted March 28, 2012 Author Share Posted March 28, 2012 I know that but i need to get ID auto by LOGGED user id stats ID = member ID Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331868 Share on other sites More sharing options...
rastaman46 Posted March 28, 2012 Author Share Posted March 28, 2012 SELECT m.memberid, p.memberid, p.uploaded, p.downloaded, p.total_posts, p.invites_left, p.points FROM tsue_members m, tsue_member_profile p WHERE p.memberid=m.memberid AND p.memberid='$get_my_id'; In php if you know what im mean. Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331869 Share on other sites More sharing options...
AyKay47 Posted March 28, 2012 Share Posted March 28, 2012 SELECT m.memberid, p.memberid, p.uploaded, p.downloaded, p.total_posts, p.invites_left, p.points FROM tsue_members m, tsue_member_profile p WHERE p.memberid=m.memberid AND p.memberid='$get_my_id'; In php if you know what im mean. and what results does this query give you Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331871 Share on other sites More sharing options...
rastaman46 Posted March 28, 2012 Author Share Posted March 28, 2012 that im put as the sample i like so this $get_my_id'; get me logged user ID auto somthing like $curuser['ID]; but i dont know how to make it Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331873 Share on other sites More sharing options...
seanlim Posted March 28, 2012 Share Posted March 28, 2012 that will depend on how your log in system works. if you are using sessions, you could store the user id in a session variable and retrieve it using $_SESSION['user_id'] Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331875 Share on other sites More sharing options...
rastaman46 Posted March 28, 2012 Author Share Posted March 28, 2012 Well all system is encoded. Any chance to make my own function to get current user ID Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331878 Share on other sites More sharing options...
AyKay47 Posted March 28, 2012 Share Posted March 28, 2012 user ids are typically stored inside of a session for use throughout the entire website. Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331881 Share on other sites More sharing options...
rastaman46 Posted March 28, 2012 Author Share Posted March 28, 2012 well if im use session im getting this Database Error! Please try again later or contact an Administrator. (1064) 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 '' at line 1 Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331938 Share on other sites More sharing options...
scootstah Posted March 28, 2012 Share Posted March 28, 2012 When you login a user you need to store the user ID in a session. In some pseudo-code; if (login == successful) { $_SESSION['user_id'] = $row['user_id']; } At the very top of each script, put session_start() so that you can access the session. In your query, do something like SELECT m.memberid, p.memberid, p.uploaded, p.downloaded, p.total_posts, p.invites_left, p.points FROM tsue_members m, tsue_member_profile p WHERE p.memberid=m.memberid AND p.memberid='$_SESSION['user_id']'; Link to comment https://forums.phpfreaks.com/topic/259870-need-litle-hellp-on-sql-query-and-php/#findComment-1331953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.