DBMS Lab-09
DBMS Lab-09
<?php
include 'db.php';
$conn->close();
?>
-----------------------------------------------------------------------------------------------------------------
<?php
$servername = "localhost";
$username = "tanush"; // Replace with your MySQL username
$password = "mypassword"; // Replace with your MySQL password
$dbname = "employee_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
-----------------------------------------------------------------------------------------------------------------
<?php
include 'db.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$id = $_POST['id'];
<!DOCTYPE html>
<html>
<head>
<title>Employee Management</title>
</head>
<body>
<h1>Employee Management System</h1>
<ul>
<li><a href="create.php">Create Table</a></li>
<li><a href="insert.php">Insert Employee</a></li>
<li><a href="select.php">View Employees</a></li>
<li><a href="update.php">Update Employee</a></li>
<li><a href="delete.php">Delete Employee</a></li>
</ul>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------
<?php
include 'db.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$position = $_POST['position'];
$salary = $_POST['salary'];
$department = $_POST['department'];
$sql = "INSERT INTO Employees (name, position, salary, department) VALUES ('$name',
'$position', $salary, '$department')";
-----------------------------------------------------------------------------------------------------------------
<?php
include 'db.php';
if ($result->num_rows > 0) {
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Name</th>
<th>Position</th>
<th>Salary</th>
<th>Department</th>
</tr>";
$conn->close();
?>
-----------------------------------------------------------------------------------------------------------------
<?php
include 'db.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$id = $_POST['id'];
$name = $_POST['name'];
$position = $_POST['position'];
$salary = $_POST['salary'];
$department = $_POST['department'];