如何在没有类别ID的情况下显示结果


How to show result without category ID

我有类别1,2,3,4,5,6,7

如何在没有类别3.的情况下显示表"news"中的所有结果。。?

tnx。

`id` int(20) NOT NULL AUTO_INCREMENT,
`title` varchar(256) NOT NULL,
`content` longtext NOT NULL,
`category` int(20) NOT NULL,

非常简单,只需使用!= 3即可。

SELECT * FROM news WHERE category != 3

执行条件where category!='查询内3'

您可以使用$cat_id来存储除结果之外的任何类别。

$cat_id = 3;
$sql = "SELECT * FROM news WHERE category!='$cat_id'";
$qry = mysqli_query($con, $sql);
if (mysqli_num_rows($qry) > 0)
{
  while ($res = mysqli_fetch_assoc($qry))
  {
   // Do the action
  }
}