Jump to content

While Statement - Excluding User IDs


Mko

Recommended Posts

So I have this code:

$skill_query = mysql_query("SELECT * FROM character_stats ORDER BY character_stats.". $fields[$skill] ." DESC LIMIT 0, $end", $c2) or print(mysql_error());
$user_query = mysql_query("SELECT user.username, user.userid, character_stats.uid FROM user, character_stats WHERE character_stats.uid = user.userid ORDER BY character_stats.". $fields[$skill] ." DESC LIMIT 0, $end") or print(mysql_error());
//WHERE user.usergroupid != 6 AND characters.banned = 0 
$rank = 1;
while($player = mysql_fetch_array($skill_query)){
if($user['userid'] != 1){
	continue;
}
$user = mysql_fetch_array($user_query);
if($rank >= $start)
output($rank, $user['username'], $user['userid'], $player['combat'], $level, number_format($exp));
$rank++;
}

 

Yet for some reason it doesn't work. I know that the

	if($user['userid'] != 1){
	continue;
}

Is the reason, but how do I fix it?

 

Basically, my goal is to display these highscores, but omit UserID 1.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/259836-while-statement-excluding-user-ids/
Share on other sites

If you want to omit user ID 1 by using the "continue" statement you should test if it is equal to one, not if it is not equal to one.

 

if(user[userID] == 1) continue;

Is there any sort of method aside from the continue statement?

Reason I ask is that whenever I use it, the output information becomes blank and doesn't display :(

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.