Delete Records on the basis of Employee ID

Published November 17, 2017 by Anil Kumar Vishwakarma

<?php
include(“db.php”);
$id = $_REQUEST[‘id’];
$delete = “DELETE FROM employees where id=$id”;
if(mysqli_query($sql, $delete)){
echo “Record Deleted”;
}else{
echo “Getting error”;
}
?>

Advertisements

Update Table Record

Published November 17, 2017 by Anil Kumar Vishwakarma

<?php
include(“db.php”);
$id = $_REQUEST[‘id’];
$first_name = $_REQUEST[‘first_name’];
$last_name = $_REQUEST[‘last_name’];
$f_name = $_REQUEST[‘f_name’];
$salary = $_REQUEST[‘salary’];
$update = “UPDATE employees set first_name=’$first_name’, last_name=’$last_name’, f_name=’$f_name’, salary=’$salary’ where id=$id”;
if(mysqli_query($sql, $update)){echo “Record updated”;}else{echo “Not updated”;}
?>

Edit Records from table

Published November 17, 2017 by Anil Kumar Vishwakarma

<?php
include(“db.php”);
$id = $_REQUEST[‘id’];
$edit = “SELECT * FROM employees where id = $id”;
$employee = mysqli_query($sql, $edit);
?>

<!DOCTYPE html>
<html lang=”en”>
<head>
<title>Bootstrap Example</title>
<meta charset=”utf-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”&gt;
https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
</head>
<body>

Employee Updation Form

0){
$emp = mysqli_fetch_assoc($employee);?>

“>

First Name:
” name=”first_name”>
Last Name:
” name=”last_name”>
Father Name:
” name=”f_name”>
Salary:
” name=”salary”>

<button type=”submit” class=”btn btn-default” onclick=”return confirm(‘Are you sure you want to Update this entry?’)”>Update</button>
<?php } ?>
</form>
</div>

</body>
</html>

Displaying All Record from Table

Published November 17, 2017 by Anil Kumar Vishwakarma

<?php
include(“db.php”);

$all_employees = “SELECT * FROM employees “;
$employee = mysqli_query($sql, $all_employees);
//print_r($employee);
?>

<!DOCTYPE html>
<html lang=”en”>
<head>
<title>All Employees Records</title>
<meta charset=”utf-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”&gt;
https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
</head>
<body>

All Employees Records

0){
while($result = mysqli_fetch_assoc($employee)){
?>

Employee ID First Name Last Name Father Name Salary Edit Delete
“>Edit ” onclick=”return confirm(‘Do you realy want to delete this record?’)”>Delete

</body>
</html>

Form for Entry of Employees

Published November 17, 2017 by Anil Kumar Vishwakarma

<!DOCTYPE html>
<html lang=”en”>
<head>
<title>Bootstrap Example</title>
<meta charset=”utf-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”&gt;
https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
</head>
<body>

Employee Submission Form

First Name:

Last Name:

Father Name:

Salary:

<button type=”submit” class=”btn btn-default”>Submit</button>
</form>
</div>

</body>
</html>

Insert Data in Table

Published November 17, 2017 by Anil Kumar Vishwakarma

<?php
include(“db.php”); //Database connection file name

$first_name = $_POST[“first_name”];
$last_name = $_POST[“last_name”];
$f_name = $_POST[“f_name”];
$salary = $_POST[“salary”];
$insert = “INSERT INTO employees(first_name, last_name, f_name, salary) values(‘$first_name’, ‘$last_name’, ‘$f_name’, ‘$salary’)”;
if(mysqli_query($sql, $insert)){
echo “Value Inserted”;
}else{
echo “value not inserted”;
}
?>

Create Table in MySQL

Published November 16, 2017 by Anil Kumar Vishwakarma

<?php
include(“db.php”); //inlude database connection

$employee= “CREATE TABLE employees(id INT PRIMARY KEY AUTO_INCREMENT NOT NULL, first_name varchar(30), last_name varchar(30), f_name varchar(30), salary INT )”;
if(mysqli_query($sql,$employee)){
echo “Table Created”;
}else{
echo “Table not created”;
}
?>