Php 如何从我的顶级名单中排除一些名字

Php 如何从我的顶级名单中排除一些名字,php,mysql,Php,Mysql,此代码在表“entries”中显示数据库中存储的所有名称的列表 我有一张200人的名单。前20名用绿色标记。最后20个红色。其他的是蓝色的 $position=0; $upit = mysql_query("SELECT * FROM entries ORDER BY votes DESC"); //This is now an array of the data while ($model = mysql_fetch_array($upit)) { $position++; $data

此代码在表“entries”中显示数据库中存储的所有名称的列表

我有一张200人的名单。前20名用绿色标记。最后20个红色。其他的是蓝色的

$position=0;

$upit = mysql_query("SELECT * FROM entries ORDER BY votes DESC");
  //This is now an array of the data

while ($model = mysql_fetch_array($upit)) {
$position++;
$data = unserialize($model['data']);
$max = mysql_num_rows($upit);
$max = $max - 20;

if ($position < 21){
echo "  <font color=#008000> ".$position." )  ".$data[6]['value']."  ( ".$model[votes]." ) </font>";

} elseif ($position <= $max) {
echo "  <font color=#000080> ".$position." )  ".$data[6]['value']."  ( ".$model[votes]." ) </font>";

} else {
echo "  <font color=#FF0000> ".$position." )  ".$data[6]['value']."  ( ".$model[votes]." ) </font>";
}
}
现在我想从列表中列出两个名字,但它们不会从数据库中删除。 每个名称在“entries”表中都有自己的唯一ID,该表中的字段称为“entries\u ID”

例如,我想从列表中删除 诺瓦克·德约科维奇的“条目id”为“150”
罗杰·费德雷斯的“条目id”是“92”

只需相应地更新查询即可

SELECT * FROM entries WHERE entries_id<>150 AND entries_id<>92 ORDER BY votes DESC
SELECT*FROM entries,其中entries_id150和entries_id92按票数排序DESC
即使这两条记录如您所愿存在于数据库中,您也无法在结果中获得它们。

尝试以下方法:

...
$count = 0;
while ($model = mysql_fetch_array($upit)) {
    $position++;
    $data = unserialize($model['data']);
    $max = mysql_num_rows($upit);
    $max = $max - 20;

    if (!($data[6]['value'] == 150 || $data[6]['value'] == 92)){
        $count++;
        if ($count< 21){
            echo "  <font color=#008000> ".$position." )  ".$data[6]['value']."  (".$model[votes]." ) </font>";
        } elseif ($count<= $max) {
            echo "  <font color=#000080> ".$position." )  ".$data[6]['value']."  ( ".$model[votes]." ) </font>";
        } else {
            echo "  <font color=#FF0000> ".$position." )  ".$data[6]['value']."  ( ".$model[votes]." ) </font>";
        }
    }
}
。。。
$count=0;
而($model=mysql\u fetch\u数组($upit)){
$position++;
$data=unserialize($model['data']);
$max=mysql\u num\u行($upit);
$max=$max-20;
如果(!($data[6]['value']==150 | |$data[6]['value']==92)){
$count++;
如果($count<21){
回显“$position.”“$data[6]['value']。”(“$model[voces]”);

}elseif($countThrow OUT!!!!这是什么意思?你想从数据库中删除它,还是从前端的列表中删除它?我想保留在列表中。这样它就不会显示。只需在PHP本身中执行。或者在(150,92)中使用
not
,所以你不需要每次都重新输入
条目。\u id?
。这就像去市场,买所有可用的巧克力,回家后说哦,不,我不需要牛奶。为什么一开始就要把所有的记录都输入?如果不需要一些记录,就不应该从数据库中获取。我同意你的观点,但这就是他想要的。他想要一段在前端威胁结果集的代码。
...
$count = 0;
while ($model = mysql_fetch_array($upit)) {
    $position++;
    $data = unserialize($model['data']);
    $max = mysql_num_rows($upit);
    $max = $max - 20;

    if (!($data[6]['value'] == 150 || $data[6]['value'] == 92)){
        $count++;
        if ($count< 21){
            echo "  <font color=#008000> ".$position." )  ".$data[6]['value']."  (".$model[votes]." ) </font>";
        } elseif ($count<= $max) {
            echo "  <font color=#000080> ".$position." )  ".$data[6]['value']."  ( ".$model[votes]." ) </font>";
        } else {
            echo "  <font color=#FF0000> ".$position." )  ".$data[6]['value']."  ( ".$model[votes]." ) </font>";
        }
    }
}