[edit]
I just saw NogDog's response, much better than mine, oh well.
[/edit]
I can give you your first tip:
For aguements sakes, Experience is 100, and Level is 10.
You are saying
$expquery = mysql_query("SELECT * FROM users WHERE exp='$exp' AND level='$newlevel'");
"Give me everyone that has Experience 100 and Levle 10" (Assuming $exp is 100 and $newlevel is 10)
$row = mysql_num_rows($expquery);
Then your assigning the number of returned rows (assume 20) to $row
while($row = mysql_fetch_assoc($expquery))
Then you are assigning $row as an array for EACH of the results - basically your last command was a waste of time, since you are over-writing $row already.
$exp = $row['exp'];
$level = $row['level'];
Then, 20x (assuming 20 users) you are making $level 10 and $experience 100 (assuming earlier values).
You are doing the SAME THING 20 times, as LEVEL and EXP are already known! (You used it in your SQL statement in the WHERE clause).
So - It is actually doing exactly what you are asking it to. Give me all users that have Experience of (assume) 100 and Level (assume) 10.
Then Make Experience 100 and Level 10
Then repeat above 19 more times (for a total of 20, hence 20 users)
..
I am not sure how the rest of your database works, but if you are able to explain a bit better (just explain like i did above, speak out the process) maybe we can help you fix it.
And provide examples, if possible, i.e. exp. 100 = level =10, 200 = 20, 300 = 30, etc.
Best of luck...