S/N | Name | - NA - | ';
}
}
echo 'Total | '; echo 'Avg | '; echo 'Position | '; echo 'Please select Form/Stream which you want to inquiry. | '; } else { echo '|||
---|---|---|---|---|---|---|---|---|---|
'.$row['st_serial_no'].' | '; echo ''.$row['st_firstname'].', '.$row['st_lastname'].' | '; // to find the records for only subject which are already submitted. // 'For' statement increase suffix of $subject# variable, until the $i value is finished. for ($k=1 ; $k<$i ; $k++){ // finding only record of the subject_id, according to assigned $subject# variables. $query2="SELECT * FROM sss_subject_record ". " LEFT JOIN sss_subject_assign". " USING (as_id)". " LEFT JOIN sss_class". " ON sss_subject_assign.class_id = sss_class.class_id". " WHERE st_serial_no='".$row['st_serial_no']."' && sss_subject_assign.class_id='".$class_id."'". " && sss_subject_assign.subject_id='".${'subject'.$k}."' && sss_subject_record.sr_submit_status != '0'"; $result2=mysqli_query($dbc,$query2) or die ('Error in Query for retrieving student subject record!'); // Check whether there is a record. if (mysqli_num_rows($result2) == 0) { // if there is not record, it means there isn't a submitted record for the subject_id. echo '-NA- | '; } else { // If there is a record, select overall average of the subject. while($row2=mysqli_fetch_array($result2)) { echo ''.$row2['sr_avg'].' | '; $total=$total+$row2['sr_avg']; break; } } } if ($i != 15){ $h=$i; for($h; $h<=15;$h++) { echo 'NA | '; } } echo ''.round($total,2).' | '; if ($i != '1') { $avg=$total/($i-1); } // To prevent an error, when there is no assigned subject yet else { $avg=0; } echo ''.round($avg,2).' | '; $query3="SELECT * FROM sss_cons_overall". " WHERE st_serial_no='".$row['st_serial_no']."' && term_id='".$_SESSION['term_id']."' && class_id='".$class_id."'"; $result3=mysqli_query($dbc,$query3) or die ('Error in Query for retrieving overall record!'); if (mysqli_num_rows($result3) == 0 ){ // $submit_status will be used to show and off the button of reposition & submit button. $submit_status='bado'; // If there is no record for the student of the class, the overall record will be inserted as first time. $query4= "INSERT INTO sss_cons_overall (st_serial_no,term_id,class_id,cons_over_total,cons_over_avg,cons_reg_date,cons_reg_by,cons_submit_status)". " VALUE('".$row['st_serial_no']."','".$_SESSION['term_id']."','".$class_id."','".$total."','".$avg."',NOW(),'".$_SESSION['user_id']."','0')"; $result4=mysqli_query($dbc,$query4) or die ('Error in Query for inserting overall record!'); echo '0 | '; } elseif (mysqli_num_rows($result3) != 0 ){ while($row3=mysqli_fetch_array($result3)) { if ($row3['cons_submit_status'] == 0) { // $submit_status will be used to show and off the button of reposition & submit button. $submit_status='bado'; // if there is an overall record, all records will be updated, when it loaded. $query5= "UPDATE sss_cons_overall". " SET cons_over_total='".$total."', cons_over_avg='".$avg."', cons_reg_date=NOW(),". " cons_reg_by='".$_SESSION['user_id']."'". " WHERE st_serial_no='".$row['st_serial_no']."' && term_id='".$_SESSION['term_id']."' && class_id='".$class_id."'"; $result5=mysqli_query($dbc,$query5) or die ('Error in Query for updating overall record!'); // from query3, retrieve current position information. echo ''.$row3['cons_over_position'].' | '; } elseif($row3['cons_submit_status'] ==1){ $submit_status='done'; // if the records are already submitted, it retrieve the position only and don't change any records. echo ''.$row3['cons_over_position'].' | '; } } } echo '