简体   繁体   English

使用mysql数据库的PHP搜索表单

[英]PHP Search Form using mysql database

I have looked on threads of the same nature and feel don't offer what looking for. 我看过相同性质的线程,觉得没有提供所需的东西。

I want to create a search form using two fields "Categories" and "Province", have table 我想使用两个字段“类别”和“省”创建搜索表

$search = $_POST['search'];
$query = $pdo -> prepare("select * from kyaami_users where services LIKE '%$search%' OR province LIKE '%$search%' LIMIT 0 , 10");
$query -> bindValue(1, "%$search%", PDO::PARAM_STR);
$query -> execute();

The problem with the above code is that it returns all the fields on the table, how can i make it to return only the user selected fields 上面的代码的问题是它返回表上的所有字段,我如何使其仅返回用户选择的字段

Try something like that: 尝试这样的事情:

$query = $pdo->prepare("SELECT * FROM kyaami_users WHERE services LIKE :services OR province LIKE :province LIMIT 0, 10");
$query->execute(array(':services' => 1, ':province' => 1));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM