I have 2 table events and categories. categories table has 2 columns id and category. The event table contains category_idas foreign key of categories table.
Now the content of events table is given by
+------------------------------------------------------+
| id | category_id | event_name | event_date | created |
+------------------------------------------------------+
| 1 | 1 | event 1 | 12-04-2016 |TIMESTAMP|
| 2 | 1 | event 2 | 14-04-2016 |TIMESTAMP|
| 3 | 2 | event 1 | 16-04-2016 |TIMESTAMP|
| 4 | 1 | event 3 | 14-04-2016 |TIMESTAMP|
| 5 | 2 | event 2 | 12-04-2016 |TIMESTAMP|
+------------------------------------------------------+
Now what I want to do is to select all rows and produce output in the form
=> Category 1
<> event 1
<><> 12-04-2016
<> event 2
<><> 14-04-2016
<> event 3
<><> 14-04-2016
=> Category 2
<> event 1
<><> 16-04-2016
<> event 2
<><> 12-04-2016
How it can be done. I am using PHP and mysqli and I want to store this information in PHP array so that I could print it anywhere in page using PHP for loop or foreach