function insert() { $tno = $_POST['tno']; $subject = $_POST['subject']; $tid = $_POST['tid']; $quantity = $_POST['quantity']; $difficulty = $_POST['difficulty']; $total = $_POST['total']; $qnos = $_POST['qnos']; $qnos = explode('@', $qnos); include '../dao/TestDaoImpl.php'; $testDao = new TestDaoImpl(); include '../dao/TtoqDaoImpl.php'; $ttoqDao = new TtoqDaoImpl(); $result = $testDao->insert($tno, $subject, $tid, $quantity, $difficulty, $total); $tests = $testDao->queryAll(); for ($i = 0; $i < count($qnos); $i++) { $result = $ttoqDao->insert($tno, $i + 1, $qnos[$i]); } session_start(); $_SESSION['tests'] = $tests; $_SESSION['tno'] = $tno; header('Location: /teacher/test.php'); }