I want to display event of json from mysql database. But i can't display it in calendar. I think there are some mistakes in events. But i can't point it out.
Here is my code:
calendar.php:
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
theme: true,
draggable: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
/*events: "json_events.php",*/
events: function(start, end, callback){
$.getJSON("json_events.php",
{
start: start.getTime(),
end: end.getTime()
},
function(result){
for(var i=0; i<result.length; i++){
var row = result[i];
}
//format the result into an array of calevents
$('#calendar').fullCalendar('addEvent', {id:row[0], title:row[1], start:row[2], end:row[3]} );
//then pass the calevent array to the callback
callback(calevents);
}
);
},
eventClick: function(event){
editEventShow(event);
},
eventDrop: function(event, daydelta, minutedelta) {
alert(event.title + ' was moved ' + daydelta + ' days\n' + minutedelta + ' minutes\n'+
'(should probably update your database)');
},
dayClick: function(dayDate){
/*$('#dialog').dialog('open');
var date, month, year;
date = dayDate.getDate();
month = dayDate.getMonth()+1;
year = dayDate.getFullYear();
dayDate = year + "-" + month + "-" + date;*/
addEventShow(dayDate, this);
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
},
});
});
</script>
<style type='text/css'>
body {
margin-top: 40px;
text-align: center;
font-size: 13px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
#calendar {
width: 900px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
</body>
</html>
json_events.php:
<?php
require("../../../connect/config.php");
$link = mysql_connect("$server","$user","$password") or die(mysql_error());
mysql_select_db($db);
$query = "SELECT id,title,start, end FROM events";
$result = mysql_query($query) or die(mysql_error());
$arr = array();
while($row = mysql_fetch_assoc($result)){
$arr[] = $row;
}
echo json_encode($arr);
?>
Can you help me about the problem??
Thanks.