fullcalendar使用php从mysql数据库获取资源

eiee3dmh  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(299)

我正在使用fullcalendar-scheduler-1.9.4。我正在尝试从我的数据库中获取资源。我通过php获取我的资源的json数组。但是,问题是我的资源的工作时间和事件颜色没有出现。更奇怪的是从5个资源中,只有一个资源得到了正确的eventcolor。我检查了php文件的输出,但它为资源提供了正确的json数组。我不知道这里怎么了。。。
下面是我的获取资源数组的php代码

<?php
$con = mysqli_connect("localhost", "dbname", "pass", "dbname");
$result = mysqli_query($con, "SELECT Teacher, color FROM TEACHERLIST WHERE Branch = '잠실';");
$response = array();

while($row = mysqli_fetch_array($result)){
    array_push($response, array("title"=>$row[0], "id" => $row[0], "eventColor" => $row[1], "businessHours" => "{start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]}"));
}

echo json_encode($response,JSON_UNESCAPED_UNICODE);
mysqli_close($con);
?>

这是我的javascript,我从中获取资源。

resources: 'teacher_J.php',
resourceAreaWidth: "10%",
eventSources:[ {url:'array_S.php'},{url:'dayS.php'}],

我的结果是这样的
使用php时出现错误的结果
正确的结果是,
正确的结果
我在没有使用php加载资源时得到了这个结果。产生正确结果的javascript代码如下

resources:[{ id: 'A', title: 'A', businessHours : {start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]} },
            { id: 'B', title: 'B', eventColor: 'green' , businessHours : {start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]}},
            { id: 'C', title: 'C', eventColor: 'orange', businessHours : {start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]} },
            { id: 'D', title: 'D', eventColor: 'Brown' , businessHours : {start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]} },
            { id: 'E', title: 'E', eventColor: 'blue' , businessHours : {start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]}}],

它们之间唯一不同的是加载资源的方式。
+)php的json输出

[
  {"title":"a","id":"a","eventColor":"MediumAquaMarine ","businessHours":"{start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]}"},
  {"title":"b","id":"b","eventColor":"green","businessHours":"{start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]}"},
  {"title":"c","id":"c","eventColor":"orange","businessHours":"{start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]}"},
  {"title":"d","id":"d","eventColor":"red","businessHours":"{start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]}"},
  {"title":"e","id":"e","eventColor":"blue","businessHours":"{start: '08:00',end: '22:30', dow: [1,2,3,4,5,6]}"}
]

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题