If i delete recored 1 next when i want to view the table i shall see recored 1 deleted and in that place recored 2 shall be named as recored one.By record i mean id
<?php
//var_dump($_POST); i used it to check if $_POST array contains the values or not.
if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'insert'){
/*Requesting page means the page which we came from and of course it expects insert page*/
$reqeusting_page = $_POST['page'];
$studentName = $_POST['name'];
$fatherName = $_POST['father'];
$schoolName = $_POST['school'];
$rollNumber = $_POST['rollno'];
$className = $_POST['class'];
if($studentName != NULL &&
$fatherName != NULL &&
$schoolName != NULL &&
$rollNumber != NULL &&
$className != NULL){
/*Now need to insert data into database*/
include("database.php");
$con = connect_database();
$status = insert($con, $studentName, $fatherName, $schoolName, $rollNumber, $className);
//close_database_connection($con);
if($status == TRUE){
header("Location: /student_example/?page=insert&success=Data Inserted Successfully!!");
}else{
header("Location: /student_example/?page=insert&error=Error: Insertion Error");
}
}else{
header("Location: /student_example/?page=insert&error=Error: All fields mendatory");
}
}else if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'delete'){
$student_id = $_REQUEST['id'];
/*Now need to delete data from database*/
include("database.php");
$con = connect_database();
$status = delete_record($con, $student_id);
//close_database_connection($con);
if($status == TRUE){
header("Location: /student_example/?page=view&success=Data Deleted Successfully!!");
}else{
header("Location: /student_example/?page=view&error=Error: Deletion Error");
}
}else if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'edit'){
$id = $_POST['id'];
$reqeusting_page = $_POST['page'];
$studentName = $_POST['name'];
$fatherName = $_POST['father'];
$schoolName = $_POST['school'];
$rollNumber = $_POST['rollno'];
$className = $_POST['class'];
if($id != NULL &&
$studentName != NULL &&
$fatherName != NULL &&
$schoolName != NULL &&
$rollNumber != NULL &&
$className != NULL){
/*here you need to update the record now*/
include("database.php");
$con = connect_database();
$status = edit_record($con, $id, $studentName, $fatherName, $schoolName, $rollNumber, $className);
if($status == TRUE){
header("Location: /student_example/?page=view&success=Record id: [".$id."] Edited Successfully!!");
}else{
header("Location: /student_example/?page=view&error=Error: Edition Error");
}
}else{
header("Location: /student_example/?page=view&error=Error: All fields mendatory");
}
}
?>