php - Database query with fullcalendar -


ok i'm trying pull events mysql database populate calendar. start times stored in unix time have used following events source.

events: {     url: '/php/booking_events.php',     type: 'post',     data: {        start: start.unix(),        end: end.unix(),        branch: branch.id_office,        instrument: inst     },     error: function() {        alert('there error while fetching events!');     }, } 

this brings first problem, when run error in dev tools saying start not defined? doesn't calendar automatically generate start , end times?

secondly, if manually enter parameters php generates json array echoes script saying 'there error while fetching events!'

    <?php     require_once('../connections/localhost.php');     require_once("../includes/functions.php");      //if (!isset($_post['start']) || !isset($_post['end'])) {     //  die("please provide date range.");     //}      //$range_start = parsedatetime($_post['start']);     //$range_end = parsedatetime($_post['end']);     //$branch = getsqlvaluestring($_post['id_office'], "int");     //$inst = getsqlvaluestring($_post['instrument'], "int");      $range_start = '1433462401';     $range_end = '1433721599';     $branch = 2;     $inst = 3;      // parse timezone parameter if present.     $timezone = null;     if (isset($_post['timezone'])) {         $timezone = new datetimezone($_post['timezone']);     }      // query database events     mysql_select_db($database_localhost, $localhost);     $query_events = sprintf("select hm_classes.datetime, hm_classes.id_student, hm_classes.inst hm_classes inner join hm_rooms on hm_classes.id_room = hm_rooms.id_room datetime between %s , %s , id_office = %s , inst = %s", $range_start, $range_end, $branch, $inst);     $events = mysql_query($query_events, $localhost) or die(mysql_error());     while ($row = mysql_fetch_assoc($events)){     $id = $row['id_class'];     $title = 'booking';     $start = date('c', $row['datetime']);     $end = date('c', ($row['datetime'] + hourstosecods($row['session'])));     $input_arrays[]= array(id => $id, title => $title, start => $start, end => $end, allday =>'false'); }       // send json client.     echo json_encode($input_arrays);     ?> 

the echoed result of is

[{"id":"1","title":"booking","start":"2015-06-05t14:00:00+02:00","end":"2015-06-05t15:00:00+02:00","allday":"false"}] 

which think fullcalendar after? appreciated.

ok think have solved problem, following kamlesh.bar's suggestion went @ http://www.jqueryajaxphp.com/fullcalendar-crud-with-jquery-and-php/.

after looking through code separated ajax request out main fullcalendar script , gave it's own function.

function getevents(){         $.ajax({             url: 'booking_events.php',             type: 'post', // send post data             data: {type: 'fetch',                    branch: $('#branch').val(),                    inst: $('#instrument').val()},             async: false,             success: function(s){                 json_events = s;             }         })     } 

then in fullcalendar set events

events: json.parse(json_events), 

this allowing results generated php entered calendar.

as start: stat.unix() issue, using strtotime in php change unix timeformat


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -