这是我用于排行榜的代码,但它显示了我想删除的管理员用户
这是我试过的代码
<?
$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);
//...
}
?>
我尝试删除的用户ID是1
我哪里错了?
答案 0 :(得分:2)
使用NOT
方法,如下所示:
SELECT id,login,email,country,coins
FROM `users`
WHERE `id`='".$top['uid']."'
AND `id` <> 1
答案 1 :(得分:2)
使用此查询
SELECT id,login,email,country,coins FROM `users` WHERE `id`='".$top['uid']."' and `id` <>'1'
答案 2 :(得分:2)
<?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
允许您跳到循环中的下一个迭代。