Reputation: 513
This is the code im using for a leaderboard but it's showing admin users which i would like to remove
here is the code i have tried
<?
$j = 0;
foreach($tops as $top){
$j++;
$user = $db->QueryFetchArray("SELECT id,login,email,country,coins FROM `users` WHERE `id`='".$top['uid']."'");
if (!in_array($user->user_id, $excluded_users))
{
$excluded_id = array(1);
//...
}
?>
The user id im trying to remove is 1
Where am i going wrong?
Upvotes: 0
Views: 125
Reputation: 3412
<?php
$j = 0;
$excluded_users = array(1);
foreach($tops as $top) {
if( in_array($top['uid'], $excluded_users ) {
continue;
}
$j++;
$user = $db->QueryFetchArray("SELECT id,login,email,country,coins FROM `users` WHERE `id`='".$top['uid']."'");
//...
}
?>
continue
lets you skip to the next iteration in the loop.
Upvotes: 2
Reputation: 3417
use this query
SELECT id,login,email,country,coins FROM `users` WHERE `id`='".$top['uid']."' and `id` <>'1'
Upvotes: 2
Reputation: 16524
Use the NOT
approach, like this:
SELECT id,login,email,country,coins
FROM `users`
WHERE `id`='".$top['uid']."'
AND `id` <> 1
Reference: Comparison Functions and Operators.
Upvotes: 2