我的数据库中的事件未显示在我的完整日历中。我使用了我在网上看过的例子中的代码,所以请加上我现在的代码。我将非常感谢你们从我们那里得到的所有帮助。谢谢!
<script>
$(document).ready(function() {
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},editable: false,
events: "json_events.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});
</script>
json_events.php
<?php
include 'connect.php';
session_start();
$result = mysql_query("SELECT ID, title, startDate AS startDate FROM events");
mysql_close();
$events = array();
while ($row=mysql_fetch_array($result)){
$title = $row['title'];
$eventsArray['id'] = $row['ID'];
$eventsArray['title'] = $title;
$eventsArray['startDate'] = $row['startDate'];
$events[] = $eventsArray;
}
echo json_encode($events);
?>
答案 0 :(得分:2)
<?php
include 'connect.php';
session_start();
$result = mysql_query("SELECT ID, title, startDate AS startDate FROM events");
mysql_close();
$events = array();
while ($row=mysql_fetch_array($result)){
$id = $row['ID'];
$title = $row['title'];
$start = $row['startDate'];
$events = array(
'id' => "$id",
'title' => "$title",
'start' => "$start"
);
}
echo json_encode($events);
?>
这对你有用。如果你不想整天都加入'allDay'=&gt; “”在开始陈述之后。“