doufu5747 2013-10-08 13:00
浏览 17
已采纳

如何从顶部列表中排除某些名称

This code displays a list of all the names that are stored in the database in the table "entries".

I have a list of 200 names. The top 20 is marked in green. Last 20 red. Others are blue.

$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>";
}
}

This CODE displays a list in the following way

 1. Novak Djokovic (1342) 
 2. Rafael Nadal (1234) 
 3. Roger Federer (1002)
 4. Name 4 (990) 
 5. Name 5 (899) 
 6. ...

Now I want to out of list two names from the list but they are not deleted from the database. Each name has its own unique ID in the table "entries" a field called "entries_id".

For example, I want to Out of list Novak Djokovic whose "entries_id" is "150" and Roger Federes hose "entries_id" is "92"

  • 写回答

2条回答 默认 最新

  • dongyan6503 2013-10-08 13:03
    关注

    Simply update your query accordingly

    SELECT * FROM entries WHERE entries_id<>150 AND entries_id<>92 ORDER BY votes DESC
    

    And you won't get those two records in your result even when they exist in database like you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?