php - full calendar always shows all events -
i have issue full calendar, working when want add events.
problem occurs categories. when calendar loads, shows events perfect. however, when change category in category select, still shows every event. don't know why doesn't update because when execute:
$this->result = mysqli_query($this->connection, "select * $this->table $this->condition");
and then:
var_dump($this->result);
i have numbers of events:
object(mysqli_result)#3 (5) { ["current_field"]=> int(0) ["field_count"]=> int(9) ["lengths"]=> null ["num_rows"]=> int(3) ["type"]=> int(0) }
3 here, , still shows 8 events.
thanks helping.
i found how work this.
the problem got sql result database , not json array datas. passed calendar object build result json function :
/** * function transform mysql results jquery calendar json * returns converted json */ public function json_transform($calendar,$js = true) { while($this->row = mysqli_fetch_array($calendar->result, mysqli_assoc)) { // set variables data db $event_id = $this->row['id']; $event_title = $this->row['title']; $event_description = $this->row['description']; $event_start = $this->row['start']; $event_end = $this->row['end']; $event_allday = $this->row['allday']; $event_color = $this->row['color']; $event_url = $this->row['url']; $event_society = $this->row['category']; if($js == true) { // js mode // when allday = false allday options appears on script, when true doesnot appear if($event_url == 'false' && $event_allday == 'false') { // build without url & allday // stores each database record array (without url) $build_json = array('id' => $event_id, 'title' => $event_title, 'description' => $event_description, 'start' => $event_start, 'end' => $event_end, 'allday' => $event_allday, 'color' => $event_color); // adds each array container array array_push($this->json_array, $build_json); } elseif($event_url == 'false' && $event_allday == 'true') { // build without url // stores each database record array (without url) $build_json = array('id' => $event_id, 'title' => $event_title, 'description' => $event_description, 'start' => $event_start, 'end' => $event_end, 'color' => $event_color); // adds each array container array array_push($this->json_array, $build_json); } elseif($event_url == 'true' && $event_allday == 'false') { // built without url & allday true // stores each database record array $build_json = array('id' => $event_id, 'title' => $event_title, 'description' => $event_description, 'start' => $event_start, 'end' => $event_end, 'allday' => $event_allday, 'color' => $event_color, 'url' => $event_url); // adds each array container array array_push($this->json_array, $build_json); } else { if($event_allday == 'false') { // built url & allday false // stores each database record array $build_json = array('id' => $event_id, 'title' => $event_title, 'description' => $event_description, 'start' => $event_start, 'end' => $event_end, 'allday' => $event_allday, 'color' => $event_color, 'url' => $event_url); // adds each array container array array_push($this->json_array, $build_json); } else { // built url & allday true // stores each database record array $build_json = array('id' => $event_id, 'title' => $event_title, 'description' => $event_description, 'start' => $event_start, 'end' => $event_end, 'color' => $event_color, 'url' => $event_url); // adds each array container array array_push($this->json_array, $build_json); } } } }
and array refresh calendar :
if(opt.filter == true) { $(opt.formfilterselector).on('change', function(e) { selected_value = $(this).val(); construct = 'filter='+selected_value; $.post('includes/cal_events.php', construct, function(response) { $(opt.calendarselector).fullcalendar('removeevents'); var obj = $.parsejson(response); $(opt.calendarselector).fullcalendar( 'addeventsource', obj); }); e.preventdefault(); }); }
cal_events.php file calls json function. need convert json array javascript : var obj = $.parsejson(response); working.
hope help.
Comments
Post a Comment