Fullcalendar を取得して、mysql テーブルから情報を取得し、その情報をカレンダーに入力しようとしています。カレンダーは表示されますが、テーブルの情報はカレンダーにありません。
これが私のコードです。
calendar.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style type='text/css'>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
#loading {
position: absolute;
top: 5px;
right: 5px;
}
#calendar {
width: 900px;
margin: 0 auto;
}
</style>
<link rel='stylesheet' type='text/css' href='fullcalendar/fullcalendar.css' />
<script type='text/javascript' src='jquery/jquery.js'></script>
<script type='text/javascript' src='jquery/ui.core.js'></script>
<script type='text/javascript' src='jquery/ui.draggable.js'></script>
<script type='text/javascript' src='fullcalendar/fullcalendar.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: true,
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>
</head>
<body>
<div id='loading' style='display:none'>loading...</div>
<div id='calendar'></div>
<p>json_events.php needs to be running in the same directory.</p>
</body>
</html>
json_events.php
<?php
include("dbstuff.inc");
$conn = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($database, $conn) or die(mysql_error());
$sql= "SELECT id, title, description, url, email, Stime, Etime, eventDate, DATE_FORMAT(eventDate, '%Y-%m-%dT%H:%i' ) AS startDate
FROM events
ORDER BY startDate DESC";
$check = mysql_query($sql) or die(mysql_error());
$events = array();
while ($row = mysql_fetch_assoc($check)) {
$eventArray['id'] = $row['id'];
$eventArray['title'] = $row['title'];
$eventArray['description'] = $row['description'];
$eventArray['url'] = $row['url'];
$eventArray['email'] = $row['email'];
$eventArray['startTime'] = $row['Stime'];
$eventArray['EndTime'] = $row['Etime'];
$eventArray['title'] = $row['Stime'] . " " . $row['title'];
$eventArray['start'] = $row['startDate'];
$eventsArray['allDay'] = "";
$events[] = $eventArray;
}
echo json_encode($events);
?>
これはMySQLファイルからのデータです
[
{
"id": "1",
"title": "07:00:00 test1",
"description": "werewr",
"url": "http://www.nba.com",
"email": "someone@host.com",
"startTime": "07:00:00",
"EndTime": "09:00:00",
"start": "2013-04-22T00:00"
},
{
"id": "2",
"title": "11:00:00 test2",
"description": "hello",
"url": "http://www.nba.com",
"email": "someone@host.com",
"startTime": "11:00:00",
"EndTime": "13:00:00",
"start": "2013-04-15T00:00"
}
]