|
-
Feb 18th, 2010, 07:14 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] go to next user?
i'm making a project where people can click on others links and well when this is clicked i want it to go to the next user thats in the 'users' table(not clicks) and well, the current user would be the receiver, now what i need is to find the user that comes after $receiver in the users table
PHP Code:
if (isset($_POST['sendclick'])) { $currentweek = date("W", time()); $clickresult = mysql_real_escape_string($_POST['clickresult']); $username = mysql_real_escape_string($_POST['username']); $receiver = mysql_real_escape_string($_POST['receiver']); if (!($username == "(Choose Username)")) { mysql_query("INSERT INTO clicks (clicker, receiver, week, message) VALUES ('".$username."', '".$receiver."', '".$currentweek."', '".$clickresult."')"); /* $nextuser will be the user after the current $receiver. what i need is to select all from users and get the next user on the list... header("Location: index.php?view=recruit&click=$nextuser"); */ } }
i put a comment in the code so i could make a bit more sense, and if this doesn't make any sense at all or almost no sense, please ask...
Last edited by Justa Lol; Feb 18th, 2010 at 08:08 AM.
-
Feb 18th, 2010, 11:22 AM
#2
Re: go to next user?
well, I don't know if $receiver holds a user ID or username, or what you want to sort by, but this should get you started.
if $receiver holds a user ID, and you want the next logical user ID (or username of that next user ID):
Code:
SELECT uid, username FROM u_users WHERE uid>$receiver ORDER BY uid ASC LIMIT 1
if $receiver holds a username, and you want the next logical user ID (or username of that next user ID):
Code:
SELECT u.uid, u.username FROM u_users u LEFT JOIN u_users r ON r.username='$receiver' WHERE u.uid>r.uid ORDER BY u.uid ASC LIMIT 1
hope that helps.
-
Feb 18th, 2010, 12:10 PM
#3
Thread Starter
Fanatic Member
Re: go to next user?
Its so complicated to explain, if I knew how to explain it properly I probably would have been able to do it without asking... But well, I think I found a solution, I'll edit this post when I've tried, right now I'm improving the design and I'm not good at multi-tasking xD
... By the way I think you got me on the right spot.
-
Feb 18th, 2010, 02:24 PM
#4
Re: go to next user?
you should probably post a reply rather than editing if you'd like some more help, because I (and also maybe anyone who has read your previous post) will not be visiting this thread again unless there's a new post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|