我希望我可以进行查询以过滤结果。当我单独发出此请求时,它会起作用:
SELECT * FROM products_details WHERE active = '1' AND category LIKE '% Phobies%';
但是在我的代码中,当进行测试时,每次都会出现此错误:
致命错误:未捕获的PDOException:SQLSTATE [42S22]:列不 找到的:C:\ laragon \ www中的``where子句''中的1054未知列 \ tresorsdufutur \ ajax.php,第36行
但是我的查询中没有IN,所有术语都来自同一列。我真的找不到或找不到我的错误。这是我的代码
$ query = "SELECT * FROM products_details WHERE active = '1'";
if (isset ($ category) &&! empty ($ category)) {
$ categorydata = implode ("','", $ category);
$ query. = "AND product_category LIKE (`$categorydata`) ";
}
答案 0 :(得分:0)
似乎是一些可能引起问题的东西
$categorydata
尝试一下
$query = "SELECT * FROM products_details WHERE active = '1'";
if (isset($category) && !empty($category)) {
$categorydata = implode ("','", $category);
$query. = " AND product_category IN ('". $categorydata. "') ";
}