CasperSecurity
<?php
session_start();
include '../../../../web/connection/connection.php';
// semester variables
$semester_name = $_REQUEST['semester_name'];
// student semester section variables
$student_semester_id = $_REQUEST['student_semester_id'];
$student_id = $_REQUEST['student_id'];
$branch_section_id = $_REQUEST['branch_section_id'];
$reside_type = $_REQUEST['reside_type'];
$is_active = 'yes';
// inserting data into semester table
$db_handle = new DBController();
$newInsert = $db_handle->tableinsert("INSERT INTO semester(semester_name)
VALUES('$semester_name')");
if($newInsert == TRUE){
echo 'Data Inserted Successfully in table 1';
//if insertion is successful in semester table then fetch a particular primary key needed
$db_handle = new DBController();
$select = $db_handle->runQuery("SELECT semester_id FROM semester WHERE semester_name = '$semester_name' ");
foreach ($select as $v){
$semester_id = $v['semester_id']; // unique primary key needed as a data for the nested table
}
// inserting data into student semester section table
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO student_semester_section(student_semester_id,student_id,branch_section_id,reside_type,is_active)
VALUES('$student_semester_id','$student_id','$branch_section_id','$reside_type','$is_active')");
if($newInsert2 == TRUE){
echo 'Data Inserted Successfully in table 2';
}else{
echo 'Not Inserted in 2' ;
}
}else{
echo 'Not Inserted in 1' ;
}
?>