0
我一直試圖讓一個PHP/mysqli簡單的搜索和運行,但我似乎無法得到它的工作。我一直在關注我在前面的問題(Link)中找到的一些指示,但它仍然無效。PHP/MySQLI多重搜索
$sql = 'SELECT product_title FROM product ';
$where = array();
$values = array();
$types = '';
if (isset($_GET['searchText']) and $_GET['searchText'] != '') {
$where[] = 'WHERE product_title = ?';
$values['titel'] = $_GET['searchText'];
$types .= 's';
}
if (isset($_GET['searchCategorySelect']) and $_GET['searchCategorySelect'] != '') {
$where[] = 'WHERE product_categoryid = ?';
$values['category'] = $_GET['searchCategorySelect'];
$types .= 's';
}
$sql .= implode(' AND ',$where);
$values = array_unshift($values, $types);
$search_stmt = $mysqli->prepare($sql);
$search_stmt->bind_param($values);
$search_stmt->execute();
導致此錯誤消息: 「錯誤的參數計數mysqli_stmt ::在... bind_param()」
一些建議或幫助,將不勝感激。
您也應該檢查你在哪裏設置你的'$ where'變量 - 你包括'WHERE'與他們每個人的;所以如果兩者都設置好了,你的SQL語句最終會有兩個'WHERE'。 – andrewsi
謝謝你告訴我,現在已經改變了。 – Markus