我的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....
)
谢谢!
您可以尝试下面的内容
$arr = array();
while($row = mysqli_fetch_assoc($query_result)) {
$id = $row['product_id'];
unset($row['product_id']);
$arr[$id] = $row;
}