Here, Is the code in this code if we remove the query then loop worked fine and if we add the Select and Insert Mysql Query then loop is running only once what is the issue in it.
for($credit=0;$credit<count($execQuery);$credit++){
$feeHeadValue = 0;
$creditAmount = $execQuery[$credit]['creditAmount'];
$query = "select
feeHeadAmount,
feeHeadId
from
fee_head_values_student
where
studentId = ?
and feeHeadId = ?
and feeCycleId = ?";
$queryArray = array($studentId,$execQuery[$credit]['feeHeadId'],$execQuery[$credit]['feeCycleId']);
$execQuery1 = $this->db->query($query,$queryArray)->result_array();
// echo"<pre>";print_r($execQuery1);
$feeHeadValue = isset($execQuery1[$credit]['feeHeadAmount']);
if(isset($feeHeadValue)){
$query ="
update
fee_head_student_wise
set
feeHeadAmount = if((feeHeadAmount + $creditAmount)<=$feeHeadValue,(feeHeadAmount + $creditAmount),feeHeadAmount)
where
studentId = ?
and feeHeadId = ?
and feeCycleId = ?
";
$queryArr = array($studentId,$execQuery[$credit]['feeHeadId'],$execQuery[$credit]['feeCycleId']);
$execQuery = $this->db->query($query,$queryArr);
}
echo $credit;
}
if i remove the Update queries then loop worked fine and if we add Update query then loop execute only once.