CodeIgniter Forums
Calender -> I just can not figure this out - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Calender -> I just can not figure this out (/thread-26343.html)



Calender -> I just can not figure this out - El Forum - 01-11-2010

[eluser]visormatt[/eluser]
I can not for the life of me figure out how to create the associative array of data to insert into the calender by way of a normal query. Any suggestions. The CI calender by default expects the array to contain (date -> link) both of which i have in my DB. I am querying and getting the relevant events properly but I am unsure of how to take that result set and output it in the format it expects.

Thank you in advance for any help.


Calender -> I just can not figure this out - El Forum - 01-11-2010

[eluser]danmontgomery[/eluser]
Code:
$data = array();
$query = $this->db->select('date, link')->get('my_table');
foreach($query->result() as $row)
{
  $data[$row->date] = $row->link;
}

echo $this->calendar->generate($year, $month, $data);



Calender -> I just can not figure this out - El Forum - 01-11-2010

[eluser]WebsiteDuck[/eluser]
Something like...
Code:
$this->load->model('events_model');
$this->load->library('calendar');

$events = $this->events_model->getEvents();

foreach ($events as $event) //from your database
{
  $data[ $event['day_number'] ] = $event['url'];
}

echo $this->calendar->generate($year, $month, $data);

If you have nonworking code, you can post it and I'll take a look


Calender -> I just can not figure this out - El Forum - 01-11-2010

[eluser]visormatt[/eluser]
Thank you both very much, working out the details now but the samples you sent over helped GREATLY!!! Thank GOD for the open source community! And once more for good measure, your help is much appreciated Smile


Calender -> I just can not figure this out - El Forum - 08-18-2010

[eluser]changereturnssuccess[/eluser]
[quote author="WebsiteDuck" date="1263270232"]Something like...
Code:
$this->load->model('events_model');
$this->load->library('calendar');

$events = $this->events_model->getEvents();

foreach ($events as $event) //from your database
{
  $data[ $event['day_number'] ] = $event['url'];
}

echo $this->calendar->generate($year, $month, $data);

If you have nonworking code, you can post it and I'll take a look[/quote]

Thank you! =)