ok
Direktori : /proc/self/root/home2/selectio/www/tnpsctestbatch.com/admin/add-api/ |
Current File : //proc/self/root/home2/selectio/www/tnpsctestbatch.com/admin/add-api/add-mock_test-form.php |
<?php include "../config/config.php"; if($_POST['type']=='add_mock_test_form'){ try{ error_log("form cliking is working"); error_log(count($_POST['question'])); for($i=0;$i<count($_POST['question']);$i++){ $mock_test_type = $_POST['mock_test']; $type = $_POST['types']; $question = $_POST['question'][$i]; $option_a = $_POST['option_a'][$i]; $option_b = $_POST['option_b'][$i]; $option_c = $_POST['option_c'][$i]; $option_d = $_POST['option_d'][$i]; $answer = $_POST['answer'][$i]; error_log("INSERT INTO `tbl_mock_test`(`exam_type`,`mock_test_type`,`question`,`option_a`,`option_b`,`option_c`,`option_d`,`correct_answer`) VALUES ($type,$mock_test_type,$question,$option_a,$option_b,$option_c,$option_d,$answer)"); $statement = $pdo->prepare("INSERT INTO `tbl_mock_test`(`exam_type`,`mock_test_type`,`question`,`option_a`,`option_b`,`option_c`,`option_d`,`correct_answer`) VALUES (?,?,?,?,?,?,?,?)"); $result=$statement->execute(array($type,$mock_test_type,$question,$option_a,$option_b,$option_c,$option_d,$answer)); } }catch(Exception $e){ $error=$e; } } if($_POST['type']=='add_test_series_form'){ try{ $test_series = $_POST['test_series']; $exam_type = $_POST['exam_type']; $description = $_POST['description']; $title = $_POST['title']; $keyword = $_POST['keyword']; $statement = $pdo->prepare("INSERT INTO `tbl_test_series`(`test_name`,`exam_type`,`description`,`title`,`keyword`) VALUES (?,?,?,?,?)"); $result=$statement->execute(array($test_series,$exam_type,$description,$title,$keyword)); }catch(Exception $e){ $error=$e; } } if($_POST['type']=='add_test_description_form'){ try{ $title = $_POST['title']; $keyword = $_POST['keyword']; $description = $_POST['description']; $type = $_POST['types']; error_log($type."check the type"); $statement = $pdo->prepare("INSERT INTO `tbl_mocktest_description`(`title`,`keyword`,`description`,`type`) VALUES (?,?,?,?)"); $result=$statement->execute(array($title,$keyword,$description,$type)); }catch(Exception $e){ $error=$e; } } if($_POST['type']=='get_test_series'){ try{ $condition = ""; if(isset($_POST["exam_type"])){ $condition.="AND exam_type=".$_POST["exam_type"]." ORDER BY id DESC"; } $exam_type = $_POST["exam_type"]; $standard_query = $pdo->prepare("SELECT * FROM tbl_test_series WHERE id !=0 ".$condition); $standard_query->execute(); $standard_result = $standard_query->fetchAll(PDO::FETCH_ASSOC); $totals = $standard_query->rowCount(); $datas=""; $datas="<option>Select Mock test Series</option>"; if($totals > 0 ){ foreach($standard_result as $standard_datas){ $datas.="<option value='".$standard_datas['id']."' >".$standard_datas['test_name']."</option>"; } }else{ $datas = "<option>No Series</option>"; } echo json_encode($datas); }catch(Exception $e){ $error=$e; } } ?>