title: How to fetch data in array from Database using PHP and MySQL
body: <p>i need one help.I need to fetch data from database and store them in an array using PHP and MySQL. My table structure is given below.</p>
  
  <blockquote>
    <p>db_special:</p>
  </blockquote>
  
  <pre><code>id     member_id      subcat_id        image         comment
  
  1       135              3             abc.png         hiii
  
  2       135              3             wsd.png         hello
  
  3       135              4             nbh.png         huuuu
  
  4       120              4             nkj.png        hghghg
  </code></pre>
  
  <p>Here the above is my table structure.I need to fetch data using the <code>member_id</code> and <code>subcat_id</code> which is given by user and it should be grouped by <code>member_id</code> .Here i need the fetched data like below format. suppose user have <code>member_id=135 and subcat_id=3</code> then result should like below.</p>
  
  <pre><code>data={"member_id":135,"subcat_id":3,"special_image"[{"image":"abc.png","comment":"hiii"},{"image":"wsd.png","comment":"hello"}]}
  </code></pre>
  
  <p>Here i need the query.Please help me.</p>