title: Select records from MYSQL database grouped by day
body: <p>I have a database of records that have a timestamp asscoiated with them. I would like to pull records from the database grouped by day, so if there are other records with the same date (24 hour span) I would like them to be grouped together. Can this be done with MYSQL or will I have to pull the records and organise them into arrays using PHP?</p>
  
  <p>Here is a screenshot of my table: </p>
  
  <p><img src="https://i.stack.imgur.com/VzDr4.gif" alt="enter image description here"></p>
  
  <p>Here is my model function so far:</p>
  
  <pre><code>public function getUsersMoves($options) {   
          $query = "SELECT * FROM myzone_user_hr_records";
          if(isset($options['GUID'])) {
              $query .= " WHERE GUID = '" . $options['GUID'] . "'";
          }
          if((isset($options['minHR'])) &amp;&amp;  isset($options['maxHR'])) {
              $query .= " AND (hr BETWEEN '" . (int)$options['minHR'] . "' AND '" . (int)$options['maxHR'] . "')";
          } else if (isset($options['zone'])) {
              $query .= " AND zone = '" . (int)$options['zone'] . "'";
          }
          if(isset($options['activity'])) {
              $query .= " AND title = '" . $options['activity'] . "'";
          }
  
          $query .= " ORDER BY time DESC";
  
          $query = $this-&gt;db-&gt;query($query);
          return $query-&gt;result_array();
      }
  </code></pre>
  
  <p>And my controller code:</p>
  
  <pre><code>$moves = $this-&gt;myzone_model-&gt;getUsersMoves($options);
  </code></pre>
  
  <p>I want the data sorted so that these records are grouped together if they have the same date in the timestamp, for example (2012-11-20). </p>
  
  <p>Thanks</p>