PDA

Click to See Complete Forum and Search --> : [RESOLVED] go to next user?


Justa Lol
Feb 18th, 2010, 06:14 AM
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

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...

kows
Feb 18th, 2010, 10:22 AM
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):
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):
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.

Justa Lol
Feb 18th, 2010, 11:10 AM
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.

kows
Feb 18th, 2010, 01:24 PM
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.