Reputation: 58
Here's the my SQL table:
order_id | product_id | deal_title | currency_code | total | date_modified
My Question is how do I make an array in PHP like in the below:
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....
)
Thanks!
Upvotes: 0
Views: 69
Reputation: 12039
You can try something like below
$arr = array();
while($row = mysqli_fetch_assoc($query_result)) {
$id = $row['product_id'];
unset($row['product_id']);
$arr[$id] = $row;
}
Upvotes: 2