• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calendar Class: multiple events on one day

#1
[eluser]ehalber[/eluser]
Hi all,

This question has been addressed before here: http://ellislab.com/forums/viewthread/54422/

But, I can't seem to get things working. My question is: how to I get multiple events on each day?

CONTROLLER
Code:
(other stuff) .......

            $year = $this->uri->segment(3);
            $year = ($year > 0) ? $year : date("Y");

            $month = $this->uri->segment(4);
            $month = ($month > 0) ? $month : date("n");
            
            $events = $this->calendarModel->getEvents($year, $month);
            
            $calendar = array();
            
            foreach ($events as $event)
            {
                $calendar[date('d', strtotime($event->date))] = $event->name;
            }
          
            $data['calendar'] = $calendar;
            
            $this->load->view('admin/calendar', $data);
MODEL:
Code:
public function getEvents($year, $month)
    {
        
        $sql = "SELECT *
                FROM (events)
                INNER JOIN event_dates
                ON events.id = event_dates.event_id
                WHERE YEAR(date) = {$year}
                AND MONTH(date) = {$month}";

        $query = $this->db->query($sql);

        if ( $query->result() > 0 )
        {
            return $query->result();
        }
    }

Thanks!


Messages In This Thread
Calendar Class: multiple events on one day - by El Forum - 02-12-2008, 11:16 AM
Calendar Class: multiple events on one day - by El Forum - 02-12-2008, 01:57 PM
Calendar Class: multiple events on one day - by El Forum - 02-12-2008, 03:14 PM
Calendar Class: multiple events on one day - by El Forum - 02-12-2008, 04:36 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.