我使用fullcalendar来显示事件,但是,它显示的是每天的所有事件,无论日期如何,如下面所示。
如何阻止这种情况发生,让日历正确显示事件?
我在“calendar.php”页面上的代码是:
$(function() {
$('#calendar').fullCalendar({
themeSystem: 'bootstrap3',
allDaySlot: 'false',
firstDay: '1',
header: {
left: 'prev, today, next',
center: 'title',
right: 'month, agendaWeek, agendaDay'
},
defaultView: 'month',
views: {
month: {
columnHeaderFormat: 'dddd'
},
agendaWeek: {
titleFormat: 'MMMM YYYY',
columnHeaderFormat: 'dddd Do'
},
agendaDay: {
titleFormat: 'MMMM YYYY',
columnHeaderFormat: 'dddd Do'
},
},
minTime: '09:00',
editable: 'true',
eventLimit: 'true',
selectable: 'true',
events: 'events.php'
});
});
“events.php”的代码是:
$connect = new PDO('mysql: host=localhost; dbname=dbName', 'userName', 'pWord');
$data = array();
$query = "SELECT bookingEnquiryNumber, IFNULL(NULLIF(groupName,''),CONCAT(firstName,' ',lastName)) AS bookingName, bookingDate, bookingStartTime, bookingFinishTime FROM tblbookingdetails WHERE accepted = 1 ORDER BY bookingDate";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
$data[] = array(
'title' => $row["bookingName"],
'date' => $row["bookingDate"],
'start' => $row["bookingStartTime"],
'end' => $row["bookingFinishTime"]
);
}
echo json_encode($data);
“events.php”的输出是:
[{"title":"Jacquenette Reichhardt","date":"2018-10-07","start":"20:00","end":"22:00"},{"title":"Haag Group","date":"2018-10-09","start":"13:00","end":"15:00"},{"title":"Nelly Tuffs","date":"2018-10-18","start":"16:00","end":"18:00"},{"title":"Aufderhar, Beatty and Anderson","date":"2018-10-22","start":"12:00","end":"14:00"},{"title":"Moore Inc","date":"2018-10-31","start":"19:00","end":"22:00"},{"title":"Ledner, Farrell and DuBuque","date":"2018-11-01","start":"19:00","end":"22:00"},{"title":"Stamm, Nicolas and Lind","date":"2018-11-04","start":"17:00","end":"19:00"},{"title":"Elvina Barnet","date":"2018-11-15","start":"10:00","end":"13:00"},{"title":"Hegmann, Armstrong and Leffler","date":"2018-11-21","start":"17:00","end":"19:00"},{"title":"Chrisy Laurie","date":"2018-11-24","start":"17:00","end":"19:00"},{"title":"Sasha Andrysek","date":"2018-12-07","start":"16:00","end":"20:00"},{"title":"Littel-Daniel","date":"2018-12-11","start":"09:00","end":"17:00"}]
我使用了jquery fullcalendar与php和mysql集成的一些代码。
我的日历页使用mysqli连接到数据库,但是events.php使用pdo(我无法让mysqli工作)。
1条答案
按热度按时间8yparm6h1#
看看文件,没有
date
仅限start
以及end
. 所以,替换具有
或者使用mysql发送
start
以及end
格式为datetimeYYYY-MM-DD HH:mm:ss