这是我的SQL表:
order_id | product_id | deal_title | currency_code | total | date_modified
我的问题是我如何在PHP中创建一个数组,如下所示:
Array
(
[product_id_num1] => Array
(
[order_id]
[deal_title]
[currency_code]
[total]
[date_modified]
)
[product_id_num2] => Array
(
[order_id]
[deal_title]
[currency_code]
[total]
[date_modified]
)
[product_id_num3] => Array
(
[order_id]
[deal_title]
[currency_code]
[total]
[date_modified]
)
etc....
)
谢谢!
答案 0 :(得分:2)
您可以尝试以下内容
$arr = array();
while($row = mysqli_fetch_assoc($query_result)) {
$id = $row['product_id'];
unset($row['product_id']);
$arr[$id] = $row;
}