-1
我的列表框就是這樣的顯示從MySQL列的所有數據由「ALL」字
<select id="brand">
<option value="All">All</option>
<option value="Acer">Acer</option>
<option value="Alcatel">Alcatel</option>
</select>
當我選擇「宏」,那麼這是很好的作品(也阿爾卡特)。但如何,我可以添加「所有」選項,選擇所有品牌show.I寫了下面的PHP code.But它不是我works.How可以創建PHP代碼爲「所有」二字
$dbClass = new Database();
$extraQuery = "";
$subcategories = json_decode($_POST['subcategories']);
if (!empty($subcategories)) {
for ($i = 0; $i < sizeof($subcategories); $i++) {
for ($j = 0; $j < sizeof($subcategories[$i]); $j++) {
if ($i == 0 && $j == 0) {
$stmt = $dbClass::Connect()->prepare("SELECT * FROM user_posts WHERE brand=:brand");
$stmt->execute(array(":brand" => $subcategories[$i][$j]));
if ($stmt->rowCount() > 0) {
$first = "brand";
if ($subcategories[$i][$j] === "All") {
$stmt = $dbClass::Connect()->prepare("SELECT * FROM user_posts WHERE $first like '%'");
$stmt->execute();
$first = $stmt;
}
$extraQuery = "WHERE (" . $extraQuery . $first . " = " . "'" . $subcategories[$i][$j] . "'";
}
}
}
}
}
$第一意味着有有更多的列我有,想將它們設置「所有」二字
<期權價值=「全部」>沒有改變。因爲它是從javascript數組中獲取的。有2個條件。