我正在使用fullcalendar库进行日历视图,
<div id="calendar">
<?PHP
include("Calendar.php");
?>
</div>
我设法使用从互联网上获取的源代码{my}}
将我的fullcalendar连接到sql dbCalendar.php
,但我怎么能自动刷新我的日历?以下是我的代码
$sql = "SELECT id, title, start, end, color FROM tbl_calendar ";
$req = $bdd->prepare($sql);
$req->execute();
$events = $req->fetchAll();
我尝试使用多种功能,例如
$('#calendar').fullCalendar({
header: {
left: 'prev,next ',
center: 'title',
right: 'today'
},
editable: true,
eventLimit: true, // allow "more" link when too many events
selectable: true,
selectHelper: true,
select: function(start, end) {
$('#ModalAdd #start').val(moment(start).format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd #end').val(moment(end).format('YYYY-MM-DD HH:mm:ss'));
$('#ModalAdd').modal('show');
},
eventRender: function(event, element) {
element.bind('dblclick', function() {
$('#ModalEdit #id').val(event.id);
$('#ModalEdit #title').val(event.title);
$('#ModalEdit #color').val(event.color);
$('#ModalEdit').modal('show');
});
},
eventDrop: function(event, delta, revertFunc) { // si changement de position
edit(event);
},
eventResize: function(event,dayDelta,minuteDelta,revertFunc) { // si changement de longueur
edit(event);
},
events: [
<?php foreach($events as $event):
$start = explode(" ", $event['start']);
$end = explode(" ", $event['end']);
if($start[1] == '00:00:00'){
$start = $start[0];
}else{
$start = $event['start'];
}
if($end[1] == '00:00:00'){
$end = $end[0];
}else{
$end = $event['end'];
}
?>
{
id: '<?php echo $event['id']; ?>',
title: '<?php echo $event['title']; ?>',
start: '<?php echo $start; ?>',
end: '<?php echo $end; ?>',
color: '<?php echo $event['color']; ?>',
},
<?php endforeach; ?>
]
});
但它不会刷新日历,但日历会一直闪烁。 任何解决方案