I am very new to javascript and json. I am trying to display the events stored in my database into a calender. But its not getting displayed.
This is my json-events.php
<?php
include("connect.php");
$year = date('Y');
$month = date('m');
$command = "SELECT * FROM planner";
$result = mysql_query($command) or die (mysql_error());
$bookings = array();
while ($row = mysql_fetch_array($result)) {
echo "hi";
$start = date("Y-m-d", strtotime($row['from_time']));
$end = date("Y-m-d", strtotime($row['to_time']));
$id = $row['plan_id'];
//$eventsArray['plan_id'] = (int)trim($myid);
//$eventsArray['title'] = $row['title'];
$title = $row['purpose'];
//$title = $row['title'];
//echo $title;
//$eventsArray['company'] = $title;
//$eventsArray['from_time'] = $start;
//$eventsArray['to_time'] = $start;
$url = "edit_calendar.php?calendarid=".$row['plan_id'];
// $eventsArray['end'] = $end;
// $eventsArray['allDay'] = false;
// $events[] = $eventsArray;
$bookings = array(
'id' => $id,
'title' => $title,
'start' => $start,
'end' => $end,
'url' => $url
);
echo json_encode($bookings);}
?>
and here i am linking that in calendar.js
jsonEvents: function() {
if($('#calendar_json').length) {
$('#calendar_json').fullCalendar({
header: {
left: 'month,agendaWeek,agendaDay',
center: 'title',
right: 'prev,next'
},
buttonText: {
prev: '<i class="icon-chevron-left icon-white cal_prev" />',
next: '<i class="icon-chevron-right icon-white cal_next" />'
},
editable: true,
firstDay: 1, // 0 - Sunday, 1 - Monday
events: "json-events.php",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days
' +
'(should probably update your database)');
}
});
}
and in my dashboard.php page
<div class="w-box w-box-green">
<div class="w-box-header"></div>
<div class="w-box-content">
<div id='calendar_json'></div>
</div>
<div class="w-box-footer">
<p class="f-text">JSON events fetched from a script</p>
</div>
</div>
But it just displays a calender not the data from database.
Can somebody plz suggest
When i echoed json-events, i get proper output
{"id":"3","title":"sdfsfsd dsdsbfb","start":"2015-01-05","end":"2015-01-14","url":"edit_calendar.php?calendarid=3"}
But in calender nothing is getting displayed