I've been bugging by this problem for like 2 weeks already, and I can't seem to find the reason why it is not working.
In my database, I have a table called 'course' where the user can add courses with schedule.
Problem: The problem is the calendar in my "edit course" page shows all the schedule of the courses stored in the table. What I want is when I want to edit the info of a specific course, the calendar should only display the schedule of that course.
My calendar shows all the schedule of all courses
Here is my controller function:
public function load()
{
$event_data = $this->crud_model->fetch_all_event();
foreach($event_data->result_array() as $row)
{
$data[] = array(
'id' => $row['id'],
'title' => $row['sched_desc'],
'start' => $row['start'],
'end' => $row['end']
);
}
echo json_encode($data);
}
Model function:
public function fetch_all_event($course_id = "")
{
$this->db->order_by('id');
$this->db->select("*");
return $this->db->get('course');
}
Script:
<script>
$(document).ready(function(){
var calendar = $('#calendar').fullCalendar({
editable:false,
header:{
left:'prev,next today',
center:'title',
right:'month,agendaWeek,agendaDay'
},
events:"<?php echo base_url(); ?>user/load"
});
});
</script>
Here is my attempt but failed to work:
public function fetch_all_event($course_id)
{
$course_details = $this->get_course_by_id($course_id)->row_array();
$id = $course_details['id'];
$this->db->order_by('id');
$this->db->select("*");
$this->db->where('id', $id);
return $this->db->get('course');
}
public function get_course_by_id($course_id = "")
{
return $this->db->get_where('course', array('id' => $course_id));
}
I hope someone here can help me, thank you.