CodeIgniter Forums

Full Version: Calender -> I just can not figure this out
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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.

El Forum

[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);

El Forum

[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

El Forum

[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

El Forum

[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! =)