KelvinLegolas KelvinLegolas - 5 months ago 12
PHP Question

How to add events in FullCalendar using an array retrieved from a mysql server (phpmyAdmin)?

I am grateful in advance of any help I receive on this. I also apologise if my error is obvious. My problem is I can't seem to find an idea on how to display all the elements of my array to populate my events.

for(var i = 0;i < count;i++)
{
// these are the arrays that contain my events
var primaryAsset = primaryAssets[i];
var release_Date = releaseDates[i];


$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
weekMode: 'liquid',
weekends: true,

events: [
{
title: primaryAsset,
start: release_Date,
end: release_Date
}
]
});
}

Answer

Please create event array first then pass into full calender like

var evt = [
    {
        title  : 'event1',
        start  : '2014-01-01'
    },
    {
        title  : 'event2',
        start  : '2014-01-05',
        end    : '2014-01-07'
    },
    {
        title  : 'event3',
        start  : '2014-01-09T12:30:00',
        allDay : false 
    }
];

then add into full calender

 $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: true,
        weekMode: 'liquid',
        weekends: true,

        events: evt
      });
Comments