【发布时间】:2019-10-19 09:14:19
【问题描述】:
我一直在尝试根据 c_type = "Engineering' 和搜索框中的搜索关键字过滤我的数据。搜索部分工作正常,但查询不工作,它显示了整个结果。
这是为了过滤我的结果
$query1 = mysqli_query($conn, "SELECT * FROM col_details WHERE c_type = 'Engineering' and c_name LIKE '%{$name}%' OR location LIKE '%{$name}%' ");
我试图在我的 col_details 表中显示所有结果,其中 c_type 是 Engineering,而 c_name 或 location 取自搜索框。 搜索框代码工作正常,但它显示的是所有数据,而不是 c_type = 'Engineering' 的数据。
任何帮助表示赞赏。
谢谢。
【问题讨论】:
-
检查
and和or一起使用的方式 - stackoverflow.com/questions/9640122/… 可能会有所帮助。