javascript - 来自 php 文件的完整日历的事件源
问题描述
我是 JS 新手,我正在尝试在日历中显示多个事件源。我查看了许多解决方案,但无法从两个文件中获取日历。它将使用 'events_source: 'event.php'' 从一个文件中获取资源。
这是加载文件的js:
var options = {
eventSources: [
{
url: 'event.php',
type: 'POST',
color: 'yellow', // a non-ajax option
textColor: 'black' // a non-ajax option
},
{
url: 'event2.php',
type: 'POST',
color: 'green', // a non-ajax option
textColor: 'black' // a non-ajax option
}
],
这是 event.php(另一个文件类似并且都可以工作)。我不确定 json_encode (最后两行)是否有问题?
$sqlBookedEvents = "SELECT AppointmentLog_ID, `appointment`.`AppointmentTitle`, `appointment`.`Date_Appointment`, `appointment`.`StartTime`, `appointment`.`EndTime`, `appointment`.`EndTime`, `user`.`FirstName`, `user`.`Surname`, `yearGroup`.`Year` FROM appointment INNER JOIN user ON `appointment`.`PupilID_AppointmentLog` = `user`.`User_ID` INNER JOIN yearGroup ON `yearGroup`.`YearGroups_ID` = `user`.`YearGroupsID`
WHERE `appointment`.`StaffID_Appointment`= '$user' ";
$resultset = mysqli_query($conn, $sqlBookedEvents) or die("database error:". mysqli_error($conn));
$calendar = array();
while( $rows = mysqli_fetch_assoc($resultset) ) {
// convert date to milliseconds
$start = strtotime($rows['Date_Appointment']) * 1000;
$end = strtotime($rows['Date_Appointment']) * 1000;
$calendar[] = array(
'id' =>$rows['AppointmentLog_ID'],
$sTime =>$rows['StartTime'],
$startTime = date("h:i", $sTime),
$eTime = $rows['EndTime'],
$endTime = date("h:ia", $eTime),
$firstname = $rows['FirstName'],
$surname = $rows['Surname'],
$year = $rows['Year'],
$dateappointment = $rows['Date_Appointment'],
$dateappointment2 = date( 'd/m', strtotime($dateappointment)),
'title' => $dateappointment2. ' | ' .$startTime. ' - ' .$endTime. ' | ' .$firstname. ' ' .$surname. ' Yr ' .$year ,
'url' => "#",
"class" => 'event-important',
'start' => "$start",
'end' => "$end"
);
}
$calendarData = array(
"success" => 1,
"result"=>$calendar);
echo json_encode($calendarData);
exit;
解决方案
推荐阅读
- c# - 如何将十进制转换为十六进制和十六进制字符串的异或
- html - 交换字体时的字体转换
- python - 如何通过生命周期配置使用 boto3 更改 S3 存储桶文件夹中所有对象的存储类?
- kubernetes - 无法通过 macvlan 访问不同工作人员(节点)中的 pod
- r - oath_listener() 需要一个交互式环境
- python - 在 python 列表中打印特定项目
- javascript - 将动态类型分配给字符串
- jquery - 悬停时如何为引导卡设置动画?
- service-worker - 如何在用户脚本中使用服务工作者
- wordpress - 让 Apache 2.4 和 mod_authn_dbd 与 Wordpress 用户数据库一起工作