CasperSecurity
<?php
session_start();
include '../../../../web/connection/connection.php';
// new time table variables
$academic_session = $_REQUEST['academic_session'];
$class_id = $_REQUEST['class_id'];
$branch_id = $_REQUEST['branch_id'];
$semester = $_REQUEST['semester'];
$no_of_period = $_REQUEST['no_of_period'];
$class_start_date = $_REQUEST['class_start_date'];
$status = $_REQUEST['status'];
$created_on = date('Y-m-d');
$created_by = $_SESSION['USER_ID'];
$is_active = 'yes';
// add new time table period variables
$day = $_REQUEST['day'];
$period = $_REQUEST['period'];
$start_time = $_REQUEST['start_time'];
$end_time = $_REQUEST['end_time'];
$syllabus_id = $_REQUEST['syllabus_id'];
$employee_id = $_REQUEST['employee_id'];
$is_active = 'yes';
// add new time table day variables
$time_table_day = $_REQUEST['time_table_day'];
$is_active = $_REQUEST['is_active'];
// inserting data into time table table
$db_handle = new DBController();
$newInsert = $db_handle->tableinsert("INSERT INTO time_table(academic_session,class_id,branch_id,semester,no_of_period,class_start_date,status,created_on,created_by,is_active)
VALUES('$academic_session','$class_id','$branch_id','$semester','$no_of_period','$class_start_date','$status','$created_on','$created_by','$is_active')");
if($newInsert == TRUE){
echo 'Data Inserted Successfully in table 1';
//if insertion is successful in time table table then fetch a particular primary key needed
$db_handle = new DBController();
$select = $db_handle->runQuery("SELECT time_table_id FROM time_table WHERE semester='$semester' ");
foreach ($select as $v){
$time_table_id = $v['time_table_id']; // unique primary key needed as a data for the nested table
}
// inserting data into time table period table
$db_handle = new DBController();
$newInsert2 = $db_handle->tableinsert("INSERT INTO time_table_period(time_table_period_id,time_table_id,day,period,start_time,end_time,syllabus_id,employee_id,is_active)
VALUES('$time_table_period_id','$time_table_id','$day','$period','$start_time','$end_time','$syllabus_id','$employee_id','$is_active')");
if($newInsert2 == TRUE){
echo 'Data Inserted Successfully in table 2';
}else{
echo 'Not Inserted in 2' ;
}
// inserting data into time table day table
$db_handle = new DBController();
$newInsert3 = $db_handle->tableinsert("INSERT INTO time_table_day(time_table_day_id,time_table_id,time_table_day,is_active)
VALUES('$time_table_day_id','$time_table_id','$time_table_day','$is_active')");
if($newInsert3 == TRUE){
echo 'Data Inserted Successfully in table 3';
}else{
echo 'Not Inserted in 3' ;
}
}else{
echo 'Not Inserted in 1' ;
}
?>