09-14-2014, 12:47 AM
[eluser]Ignis Avis[/eluser]
Following is the model function I use to get late fee from the database
In my controller i am using following code to call it.
when passing to the view it generates following error
and in view this is the code
So i dumped the $data[late_info] which is null. so i wanted to see what query was executing.
I found the query and ran it in mysql it generates perfect row which I inteded to generate.
but for model function above, following query is generated. one extra parameter. I have no idea from where it is getting it.
Its weird! to me. so rest of my controller function look like
So i'm kind of stuck. Please give me some guidelines.
Following is the model function I use to get late fee from the database
Code:
function get_late_fee_by_id($id) {
$month = date("F, Y", time());
$this->db->select('mwf_late_fee,total_due');
$this->db->from('mwf');
$this->db->where('mwf_student_id',$id);
$this->db->where('mwf_month',$month);
}
In my controller i am using following code to call it.
Code:
$data['late_info'] = $this->transaction_model->get_late_fee_by_id($this->uri->segment(3));
when passing to the view it generates following error
Code:
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/invoice.php
Line Number: 95
and in view this is the code
Code:
<?php foreach($late_info as $late) { ?>
<tr>
<td></td>
<td>Late Fee</td>
<?php echo '<td class="right"><strong>'. $late['mwf_late_fee'].'</strong></td>'; ?>
</tr>
So i dumped the $data[late_info] which is null. so i wanted to see what query was executing.
I found the query and ran it in mysql it generates perfect row which I inteded to generate.
but for model function above, following query is generated. one extra parameter. I have no idea from where it is getting it.
Code:
SELECT `mwf_late_fee`, `total_due`, `grade` FROM (`mwf`, `student_info`) WHERE `1mwf_student_id` = 'MCS20145B53' AND `mwf_month` = 'September, 2014' AND `student_gen_id` = 'MCS20145B53'
Its weird! to me. so rest of my controller function look like
Code:
public function generate_invoice() {
$data['fin_info'] = $this->student_model->get_financial_info($this->uri->segment(3));
$data['stu_info'] = $this->student_model->get_student_info($this->uri->segment(3));
$data['late_info'] = $this->transaction_model->get_late_fee_by_id($this->uri->segment(3));
$dt_id = $this->student_model->get_grade_by_id($this->uri->segment(3));
$data['grade_info'] = $this->transaction_model->get_grade_info_by_id($dt_id[0]['grade']);
//load the view
$data['content'] = 'invoice';
$this->load->view('layout', $data);
}
So i'm kind of stuck. Please give me some guidelines.