Welcome Guest, Not a member yet? Register   Sign In
How to split db result with date values into single day groups
#4

[eluser]LuckyFella73[/eluser]
What Aken posted was my first intention but the problem was
that I had a time format like this in my DB table:
Code:
2012-08-13 14:15:00

and my loop had to "ignore" the part after the day value to
get the needed result.

In the end I get it to work this way:
Code:
$query = $this->db->query('SELECT * FROM '.$table_name.' GROUP BY DATE(start)'); // this mysql function "filters" by the Y-m-d value

  echo '<div class="items">';

  foreach ($query->result_array() as $row)
  {
   $start_date_complete = strtotime($row['start']);
   $date_ymd = date("Y-m-d", $start_date_complete);

   echo $this->get_day_wrapper_start($date_ymd);
   echo $this->get_info($date_ymd).'<br><br>';
   echo $this->get_day_wrapper_end();
  }
  echo '</div>';

Thanks to both of you for your replies !!


Messages In This Thread
How to split db result with date values into single day groups - by El Forum - 08-14-2012, 06:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB