简体   繁体   中英

EventSources with sql not working in Fullcalendar

Hello im trying to use EventSources to get multiple events in the same calendar with sql, but when I try to do it like the fullcalendar docs the calendar goes blank. What am I doing wrong? Here is my code for the callendar

                      <script type="text/javascript">
                    document.addEventListener('DOMContentLoaded', function() { // DOMContentLoaded zorgt ervoor dat eerst de html laad
                      var calendarEl = document.getElementById('calendar'); // grab element reference

                      var calendar = new FullCalendar.Calendar(calendarEl, {
                        // Opties in fullcalendar
                        eventLimit: true,
                        locale: 'nl',
                        buttonText: {
                          month: 'Maand',
                          agendaDay: 'Dag',
                          agendaWeek: 'Week',
                          today: 'Vandaag',
                          listMonth: 'Lijst'
                        },
                        header: {
                          left: 'prev,next today',
                          center: 'title',
                          right: 'listMonth,month,agendaWeek,agendaDay'
                        },
                        eventSources: [
                          '/sql.php',
                          '/availability.php'
                        ]
                      });

                      calendar.render();
                    });
                  </script>

Your php file must return the events as a json feed,

Example :

<?php
$event_array = array();

while ($row = $getCalenderItems->fetch()) {

    $event_array[] = array(
        "title" => $row['Docentnaam'] . ' ' . $row['Onderdeelnaam'] . ' ' . $row['Opleidingnaam'] . ' ' . $row['LocatiePlaats'],
        "start" => new Date($row['Start']),
        "end" => new Date($row['Eind'])

    );
}

echo json_encode($event_array);


?>

Adjust your php files to return json feed to the source of the calendar as shown above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM