Good day! I'd like to seek some help about making a summary report page from a database. I have 4 tables in my database: 'courses' table, 'enrolment_profile' table, 'enrolment_setup' table, 'students' table
This is my desired result: Summary Report Page
So far all of my codes (controllers, models and other views) are working except the view for that desired result. Here are my working codes:
a. application/controllers/Query.php
<?php
class Query extends CI_Controller{
public function __construct(){
parent::__construct();
}
public function index(){
$data['title'] = 'Queries';
$this->load->view('queries', $data);
}
public function enrolment_summary(){
$data['title'] = 'Enrolment Summary';
if($this->uri->segment(3)=='view'){
if(!isset($_POST['btnsubmit'])){
redirect(base_url('query/enrolment_summary'));
}
$datestart = $this->input->post('txtdatestart');
$dateend = $this->input->post('txtdateend');
$this->load->model('reports_model');
$data['students'] = $this->reports_model->query_enrolmentSummary_dateBetween($datestart,$dateend);
$this->load->view('query_enrolment_summary', $data);
}else{
$this->load->view('query_form_enrolment_summary', $data);
}
}
}
?>
b. application/models/report_lookup_model.php
<?php
class report_lookup_model extends CI_Model{
public function __construct(){
parent::__construct();
$this->load->database();
}
public function r_value($table, $field, $key, $return){
$rs = $this->db->get_where($table, array($field => $key));
$row = $rs->row();
return $row->$return;
}
}
?>
c. application/models/reports_model.php
<?php
class Reports_model extends CI_Model{
public function __construct(){
parent::__construct();
$this->load->database();
}
public function query_enrolmentSummary_dateBetween($start_date, $end_date){
$this->load->model('report_lookup_model');
$sem = $this->report_lookup_model->r_value('enrolment_setup', 'enr_setup_id', 1, 'sem');
$schYr = $this->report_lookup_model->r_value('enrolment_setup', 'enr_setup_id', 1, 'schYr');
$this->db->where("date(enr_dateEnrolled) BETWEEN '$start_date' and '$end_date'");
$rs = $this->db->get('enrolment_profile');
return $rs->result_array();
}
}
?>
d. application/views/queries.php
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1>Queries</h1>
<ul>
<li><a href="<?php echo base_url('query/enrolled_students'); ?>">Enrolled Students</a></li>
<li><a href="<?php echo base_url('query/not_enrolled_students'); ?>">Not Enrolled Students</a></li>
<li><a href="<?php echo base_url('query/all_students'); ?>">All Students</a></li>
<li><a href="<?php echo base_url('query/enrolment_summary'); ?>">Enrolment Summary</a></li>
</ul>
</body>
</html>
e. application/views/query_form_enrolment_summary.php
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1><?php echo $title; ?></h1>
<?php echo form_open('query/enrolment_summary/view'); ?>
<label>Select Start Date</label>
<input type="date" name="txtdatestart" /> <br />
<label>Select End Date</label>
<input type="date" name="txtdateend" /> <br />
<?php echo form_submit('btnsubmit', 'Submit'); ?>
<?php echo form_close(); ?>
</body>
</html>
Those are the codes that I finished already, now I just need the code for the view (application/views/query_enrolment_summary.php) of the desired result.