I have a MySQL query that returns the following result:
+----------+----------+-------+
| ApptTime | ApptType | Count |
+----------+----------+-------+
| 16:00 | pickup | 1 |
+----------+----------+-------+
| 16:30 | dropoff | 1 |
+----------+----------+-------+
| 16:30 | pickup | 6 |
+----------+----------+-------+
| 16:45 | pickup | 2 |
+----------+----------+-------+
| 16:45 | dropoff | 1 |
+----------+----------+-------+
I need to loop through the result and create a new associative array where the key is the ApptTime and the value is the combination of ApptType and Count like so:
"16:00" => "1 pickup"
"16:30" => "1 dropoff, 6 pickup" //the order in which appointments are listed is irrelevant.
"16:45" => "1 dropoff, 2 pickup"
I've tried looping through the mysqli_fetch_assoc result in a variety of ways and creating a new array within the loop but I'm fundamentally not understanding how to go about it so it's not working out.
Any help is greatly appreciated.