基本上我不会能够抓住所有项目并将它们插入数组中,此时我已经制作了类别数组,但我似乎无法获得数组中的所有项目只有一个项目进入每个部分
$sql2 = "SELECT * FROM products group by Market ";
$result2 = $conn->query($sql2);
// GETS all Category
$sql = "SELECT DISTINCT Category FROM products group by Category";
$result = $conn->query($sql);
$array = array();
while ($row = $result->fetch_assoc()) {
$array[$row['Category']] = array();
}
while ($row = $result2->fetch_assoc()) {
$array[$row['Category']] = array($row['Market']);
}
目前输出
但是每个类别都有更多的项目,例如,看看SQL有2个摄像机市场,在我看来它不是循环所有子类别或覆盖它们
SELECT * FROM products where Category = 'CAMCORDERS' group by Market