hi all,
I have a strange problem in my application. unable to loop through an array.
here my code:
Controller:
Code:
public function rep_fee_invoice_4class()
{
$data = array(
//'fee_type' => $this->input->post('fee_type'),
'id' => $this->input->post('class')
);
$this->data['fee_detail']= $this->Fee_model->get_fee_invoice_4class($data);
$this->load->view('reports/rep_fee_invoice_4class_html', $this->data , TRUE);
}
Model:
Code:
public function get_fee_invoice_4class($data){
$class_condition = "WHERE studentclass=". $data['id'];
$student_query=$this->anotherDb->query("SELECT * from
users $class_condition
AND activated =1
AND role = 'Student'");
$totalrows = $student_query->num_rows();
for($i=0;$i<$totalrows;$i++) {
$result = $student_query->result_array();
$student_id = $result[$i]['id'];
$student_condition = "WHERE paymentStudent=". $student_id;
$query=$this->anotherDb->query("
SELECT paymentStudent, feeMonth, paymentDescription, paymentamount
FROM payments
$student_condition
AND date_format(feeMonth, '%d-%m-%Y') >= date_format(curdate(), '00-%m-%Y')
AND PAYMENTSTATUS =0");
}
return $query->result_array();
}
View:
Code:
<?php
do {
?> <table>
<?php
if(isset($fee_detail) && is_array($fee_detail) && count($fee_detail)): $i=1;
foreach ($fee_detail as $key => $data) {
?>
<tr>
<td style=" border: 1px solid #555555;"><?php echo $i; ?></td>
<td style=" border: 1px solid #555555;"><?php echo $data['paymentStudent']; ?></td>
<td style=" border: 1px solid #555555;"><?php echo $data['paymentDescription']; ?></td>
<td style=" border: 1px solid #555555;"><?php echo $data['paymentamount']; ?></td>
</tr>
<?php
$i++;
}
else:
?>
<tr>
<td style=" border: solid 1px #000000 colspan="8" >No Records Found..</td>
</tr>
<?php
endif;
?>
</tbody>
</table>
<?php
}
while ($fee_detail);
?>