title: how to group mysql based on items and today date
body: <p>I have a database that store transaction logs, I would like to count all the logs for that day and group them based on prod_id</p>
  
  <p>MySQL table structure:</p>
  
  <p>Table name = <code>products</code></p>
  
  <pre><code>+------+---------+------------+--------+
  | ID   | PROD_ID | DATE       | PERSON |
  +------+---------+------------+--------+
  |    1 |       2 | 1400137633 |      1 |
  |    2 |       2 | 1400137666 |      1 |
  |    3 |       3 | 1400137125 |      2 |
  |    4 |       4 | 1400137563 |      1 |
  |    5 |       2 | 1400137425 |      2 |
  |    6 |       3 | 1400137336 |      1 |
  +------+---------+------------+--------+
  </code></pre>
  
  <p><strong>MYSQL CODE</strong>:</p>
  
  <pre><code> $q = 'SELECT count(ID) as count 
           FROM PRODUCTS 
          WHERE PERSON ='.$db-&gt;qstr($person).' 
            AND DATE(FROM_UNIXTIME(DATE)) = DATE(NOW())';
  </code></pre>
  
  <p>so what I get is the number of items for the given date. Since the date is the same as all other entries. however I would like to group the items by prod_id, I tried GROUP BY PROD_ID but that did not give me what I want. I would like it to group if the <code>PROD_ID</code> is multiple and the date is the same display as one entry while still count the others</p>
  
  <p>so here I should get an output ($Person = 1).... 2+2+2=1 +3 +4 so total should be 3</p>
  
  <p>any suggestions?</p>