Talha Sarwar Talha Sarwar - 3 months ago 9
PHP Question

i amtrying to fetch dates from mysql db to fullcalender.js events

i have a table in my database named as employee_leaves,have fields like starting date and ending date i want to fetch those dates and display them dynamically on full calender so far i have done this
but everytimes the alert is executed alerting the error...

$(document).ready(function() {
var calender= $('#cal').fullCalendar({

events: {
url:"events.php",
type:"POST",
error: function() {
alert('There was an error while fetching events.');
}
}
})

});


this is my events.php file

$sql_get_leaves="SELECT * from employee_leaves";
$query_leaves=mysql_query($sql_get_leaves);
$events-array();
$res=mysql_fetch_array($query_leaves);
$e=array();
$e['id']="Leave_1";
$e['title']="Leave";
$e['start']=$res['leave_starting_date'];
$e['end']=$res['leave_ending_date'];
$e['allDay']=false;
array_push($events,$e);
echo json_encode($events);

Answer

Check the code properly. For ( = ) you have written as ( - ) Change and try:-

$events = array();

And also add the success function in our javascript function.

Comments