来自mysql数据库的完整日历事件源

时间:2016-05-26 19:07:54

标签: php jquery mysql fullcalendar

所以我在过去的两天里一直在努力让完整的日历插件从我的mysql数据库中提取事件。我在calendar.html中设置了日历,并将事件源设置为从events.php中提取。 Events.php查询数据库,然后将结果输出为json数组。根据我的理解,完整日历应该将此数组转换为日历上的事件,但它没有显示任何内容。我检查了控制台,它也没有给我任何错误。我真的很感激任何帮助。

Calendar.html

    <!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../fullcalendar.css' rel='stylesheet' />
<link href='../fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='../lib/moment.min.js'></script>
<script src='../lib/jquery.min.js'></script>
<script src='../fullcalendar.min.js'></script>
<script>

    $(document).ready(function() {

        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,basicWeek,basicDay'
            },
            selectable: true, 
            contentHeight: 600,
            defaultDate: '2016-05-12',
            editable: false,
            eventLimit: true, // allow "more" link when too many events
            events: '/events.php',
        });

    });

</script>
<style>

    body {
        margin: 40px 10px;
        padding: 0;
        font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
        font-size: 14px;
    }

    #calendar {
        max-width: 900px;
        margin: 0 auto;
    }

</style>
</head>
<body>

    <div id='calendar'></div>

</body>
</html>

events.php - 为安全起见我删除了mysql登录信息

<?php

    $host= "localhost";
    $user= "";
    $pass= "";
    $db="";
    $connection = mysqli_connect($host, $user, $pass, $db) or die("Error " . mysqli_error($connection));
    if ($connection->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 
    echo "Connected successfully";



    $res = mysqli_query($connection,"SELECT * FROM jobs") or die("Error");


    $emparray = array();
    while($row =mysqli_fetch_assoc($res))
    {
        $emparray[] = $row;
    }
    echo json_encode($emparray);


    mysqli_close($connection);
 ?>

Json数组输出

Connected successfully[{"id":"1","title":"Betty's Blocks","pay":"20.00","description":"My neighbor Betty has some relatively small piles of concrete and stone debris that she needs cleaned up and transported off of her property. She also asked us to shovel and rake the area so it no longer has irregular holes. It should take us 1-2 hours. Meet at my house at 9:00 am","location":"Test","max_people":"3","people_going":"2","tasks":"You'll have to: move concrete\/stone debris, shovel, rake,","start_time":"12:00:00","end":"13:00:00","start":"2016-05-26 00:00:00"},{"id":"2","title":"Test Two","pay":"4.00","description":"This is another Test","location":"Test location two","max_people":"4","people_going":"1","tasks":"This is a test","start_time":"13:00:00","end":"15:00:00","start":"2016-05-30 00:00:00"}]

0 个答案:

没有答案