简体   繁体   English

如何添加更多要搜索的内容

[英]How to add more things to search

I'm trying to make search script on php.我正在尝试在 php 上制作搜索脚本。 For now it's only searching for serialkey in database, but I want to add more.现在它只是在数据库中搜索serialkey,但我想添加更多。

$search = $conn->prepare("SELECT `id`, `serialkey`, `discordid`, `orderid`, `date` FROM `serials` WHERE `serialkey` LIKE ?");
$search->execute(array("%$q%"));

I tried to use我试着用

$search = $conn->prepare("SELECT `id`, `serialkey`, `discordid`, `orderid`, `date` FROM `serials` WHERE `serialkey` LIKE ? or `discordid` LIKE ?");

But it didn't work, just getting error但它没有用,只是出错

Invalid parameter number: number of bound variables does not match number of tokens无效的参数编号:绑定变量的数量与令牌数量不匹配

Even if you want to compare multiple columns against the same value, you must bind it the number of times you have used the placeholder.即使您想将多个列与同一个值进行比较,您也必须将其绑定到您使用占位符的次数。 If you have used two placeholders you need to bind the same value twice.如果您使用了两个占位符,则需要两次绑定相同的值。

$search = $conn->prepare("SELECT `id`, `serialkey`, `discordid`, `orderid`, `date` 
    FROM `serials` 
    WHERE `serialkey` LIKE ? or `discordid` LIKE ?");
$search->execute(["%$q%", "%$q%"]);

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

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