title: SQL join two tables to give multi array result
body: <p>I have 2 table <code>events</code> and <code>categories</code>. <code>categories</code> table has 2 columns <code>id</code> and <code>category</code>. The <code>event</code> table contains <code>category_id</code>as foreign key of <code>categories</code> table.</p>
  
  <p>Now the content of <code>events</code> table is given by</p>
  
  <pre><code>+------------------------------------------------------+
  | 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|
  +------------------------------------------------------+
  </code></pre>
  
  <p>Now what I want to do is to select all rows and produce output in the form</p>
  
  <pre><code>=&gt; Category 1
       &lt;&gt; event 1
       &lt;&gt;&lt;&gt; 12-04-2016
       &lt;&gt; event 2
       &lt;&gt;&lt;&gt; 14-04-2016
       &lt;&gt; event 3
       &lt;&gt;&lt;&gt; 14-04-2016
  =&gt; Category 2
       &lt;&gt; event 1
       &lt;&gt;&lt;&gt; 16-04-2016
       &lt;&gt; event 2
       &lt;&gt;&lt;&gt; 12-04-2016
  </code></pre>
  
  <p>How it can be done. I am using <code>PHP</code> and <code>mysqli</code> and I want to store this information in PHP array so that I could print it anywhere in page using PHP <code>for</code> loop or <code>foreach</code></p>