Question

In documentation I have seen, To add multiple events they used:

$('#calendar').fullCalendar({
    events: [
        {
            title  : 'event1',
            start  : '2010-01-01'
        },
        {
            title  : 'event2',
            start  : '2010-01-05',
            end    : '2010-01-07'
        },
        {
            title  : 'event3',
            start  : '2010-01-09 12:30:00',
            allDay : false // will make the time show
        }
    ]
});

But I am unable to insert multiple event on this where event date will be provied by db. So One loop is necessary for multiple event. Can somebody help me to this ?

Était-ce utile?

La solution

I'll assume that your are using PHP. Last time i used full calendar, i was fetching with JSON and i builded an array of data in PHP.

I had a php file named get_events.php

$result    =  mysql_query($query);
$jsonArray = array();

while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

    $start = $row['heuredebut'];
    $end   = $row['heurefin'];

    // Stores each database record to an array
    $buildjson = array(
        'id'     => $row['id'],
        'uid'    => $row['uid'],
        'title'  => $row['title'],
        'start'  => "$start",
        'end'    => "$end",
        'allDay' => false
    );

    // Adds each array into the container array
    array_push($jsonArray, $buildjson);

}
// Output the json formatted data so that the jQuery call can read it
echo json_encode($jsonArray); 

JQuery:

$('#calendar').fullCalendar({
   events:'get_events.php'
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top