我正在用mysql数据库创建一个php网页搜索,
正如您在我的html搜索表单上方的图片中看到的那样,我通过POST传递了三个值。
PHP代码:
public static void main(String[] args){
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame gui=new JFrame();
gui.setSize(800, 800);
gui.setVisible(true);
NewJPanel panel=new NewJPanel();
//panel.setLayout(null);
panel.add(button);
gui.add(panel);
}
});
}
问题是我总是得到与数据库中第一个相同的结果。
即使我让所有字段都空了。
<?php
$search_name =$this->filter($_POST["name"]);
$search_location=$this->filter($_POST["location"]);
$search_speciality=$this->filter($_POST["category"]);
$sql="SELECT * FROM pro
WHERE ('pro_fname' LIKE '%".$search_name."%') OR ('pro_speciality' LIKE '%".$search_speciality."%') OR ('pro_location' LIKE '%".$search_location."%') and Pro_category='Doctor'";
?>
我用它来分隔结果,因为我有两个类别医生和药房,此搜索只针对医生
答案 0 :(得分:0)
尝试正确封闭您的条件,我的意思是
WHERE (condition1 or condition2 or condition3) and condition4