this is not a complete answer, but I like your code for the $_POST['next'] portion. i would start by making one change, however. you have:
"SELECT uid FROM lagina . users WHERE uid > $id"
I would add:
"SELECT uid FROM lagina . users WHERE uid > $id LIMIT 1"
This will give you only one result, which is what I think you're looking for anyway. And instead of using mysql_fetch_array to get the results, use mysql_result(select_1,0,'uid')