html - PHP, Codeigniter: Foreach Should Echo Multiple Rows when accessed in Controller -
hi guys summarize problem here hope understand.
main goal: have on change event depend on selected values in month access controller , echo multiple rows or result.
already accomplished: have on change event in multiple select trigger controller , access rows.
the on change event:
$('#month').change(function() { var values = $(this).val(); // returns array // loop on values values.foreach(function(val){ if (val == 1) { $("#nomonthschoolfees").load(baseurl+'/admin/summary/nomonthschoolfees/'+studentid+'/'+schoolyearid); // access controller if 1 selected in multiple select. } else if (val == 2) { } }); });
main problems:
problem 1: 1st problem is, when echoing row, results of datas outside select option box.
problem 2: i've tried query in mysql, should show @ least 2 rows, showing/echoing 1 result of foreach inside controller.
screenshot of forms , problem:
main code (controller):
public function nomonthschoolfees($studentid = null, $schoolyearid = null) { if ($studentid && $schoolyearid) { $studentfeesdata = $this->model_feestudent->nomonthschoolfees($studentid, $schoolyearid); if ($studentfeesdata) { $arraynumber = 0; foreach($studentfeesdata $x => $studentfees) { $rows = ' <tr id="row'.$x.'" class="'.$arraynumber.'"> <td class="form-group"> <select style="width: 400px; text-align-last:center;" class="form-control" name="subparticulars['.$x.']" id="subparticulars'.$x.'" readonly/> <option value="'.$studentfees['feetype_id'].'"> '.$studentfees['feetype_name'].' </option> </select> </td> <td class="form-group"> <input type="text" class="form-control" name="subpaymentbalance[<?php echo $x; ?>]" id="subpaymentbalance<?php echo $x; ?>" onclick="copybalance('.$x.')" style="text-align:center;" value="'.$studentfees['feestudent_amount'].'" readonly /> </td> </tr>'; $arraynumber++; }// end of foreach }// end of if ($studentfeesdata) } // end of if ($studentid && $schoolyearid) echo $rows; // echo results of rows. }// end of function
you overwritting $rows
each loop.
replace
... $rows = ' <tr id="row'.$x.'" class="'.$arraynumber.'"> ...
with
public function nomonthschoolfees($studentid = null, $schoolyearid = null) { $rows = ''; ... $rows .= ' <tr id="row'.$x.'" class="'.$arraynumber.'"> ...
also fix closing tag (look @ backslash on end):
<select style="width: 400px; text-align-last:center;" class="form-control" name="subparticulars['.$x.']" id="subparticulars'.$x.'" readonly/>
with
<select style="width: 400px; text-align-last:center;" class="form-control" name="subparticulars['.$x.']" id="subparticulars'.$x.'" readonly>
Comments
Post a Comment