Jump to content

Need litle hellp on sql query and php


rastaman46

Recommended Posts

Hello im just beginner on this side.

 

Here what im trying to do but not successful  :shrug:

 

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

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

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.

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

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 

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']';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.