function doAssignsubj() { global $mydb; $bureauId = $_GET['bureauId']; $SY = $_GET['SY']; $bureauId = $_GET['bureauId']; $cid = $_GET['cid']; $sy = $_GET['sy']; $subjectId = $_POST['selector']; $subjId = count($subjectId); if (!$subjectId == '') { echo $selector, $selector; $mydb->setQuery("SELECT * FROM `schoolyr` WHERE `AY` ='{$SY}' AND `IDNO`='{$bureauId}'"); $res = $mydb->loadSingleResult(); //echo $res->SYID . '<br/>'; for ($i = 0; $i < $subjId; $i++) { $mydb->setQuery("SELECT * \n\t\t\t\tFROM `subject` s ,`course` c \n\t\t\t\tWHERE s.`COURSE_ID`=c.`COURSE_ID` AND SUBJ_ID='{$subjectId[$i]}'"); $cur = $mydb->loadResultlist(); foreach ($cur as $result) { $grades = new Grades(); $grades->SUBJ_ID = $result->SUBJ_ID; $grades->IDNO = $bureauId; $grades->INST_ID = 'NONE'; $grades->SYID = $res->SYID; $grades->PRE = 'NONE'; $grades->MID = 'NONE'; $grades->FIN = 'NONE'; $grades->FIN_AVE = 'NONE'; $grades->DAY = 'NONE'; $grades->G_TIME = 'NONE'; $grades->REMARKS = 'NONE'; $grades->create(); } message("bureau's subjects already Added!", "info"); redirect('index.php?view=subject&bureauId=' . $bureauId . '&cid=' . $cid . '&sy=' . $sy . ''); } } else { message("Select first the subject(s) you want to Add!", "error"); redirect('index.php?view=subject&bureauId=' . $bureauId . '&cid=' . $cid . '&sy=' . $sy . ''); } }