View Data
<!DOCTYPE html><html>
<head>
<title>View Records</title>
</head>
<link rel="stylesheet" type="text/css" href="assets/libs/bootstrap/css/bootstrap.css">
<script type="text/javascript" src="assets/libs/bootstrap/js/bootstrap.js"></script>
<body>
<header>
<?php include 'shared/header.html'; ?>
</header>
<?php
include 'db.php';
$query = "SELECT * from maid_info";
$result = mysqli_query($conn,$query) or die(mysqli_error());
?>
<table class="table">
<tr>
<th>ID</th>
<th>First Name</th>
<th>Middel Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Phone No</th>
</tr>
<?php
while ($record = mysqli_fetch_assoc($result)) {
echo "<tr>" ;
echo "<td>".$record['mid']."</td>";
echo "<td>".$record['mfname']."</td>";
echo "<td>".$record['mmname']."</td>";
echo "<td>".$record['mlname']."</td>";
echo "<td>".$record['mg']."</td>";
echo "<td>".$record['pno']."</td>";
echo "<td><a href='edit.php?id=".$record['mid']."'>Edit</a></td>";
echo "<td><a href='delete.php?id=".$record['mid']."'>x</a></td>";
echo "</tr>";
}
?>
</table>
<script type="text/javascript" src="assets/js/jquery-3.1.0.js"></script>
</body>
</html>
Edit Page
<html>
<body>
<?php
include('db.php');
if(isset($_GET['id']))
{
$id=$_GET['id'];
if(isset($_POST['submit']))
{
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$query3=mysqli_query($conn,"update maid_info set mfname='$fname', mlname='$lname' where mid='$id'");
if($query3)
{
header('location:view.php');
}
}
$query1=mysqli_query($conn,"select * from maid_info where mid='$id'");
$query2=mysqli_fetch_array($query1);
?>
<form method="post" action="">
Name:<input type="text" name="fname" value=" <?php echo $query2['mfname']; ?>" /><br />
Age:<input type="text" name="lname" value="<?php echo $query2['mlname']; ?>" /><br /><br />
<br />
<input type="submit" name="submit" value="update" />
</form>
<?php
}
?>
</body>
</html>
Edit record
<html>
<body>
<?php
include('db.php');
if(isset($_GET['id']))
{
$id=$_GET['id'];
$query1= mysqli_query($conn,"delete from maid_info where mid='$id'");
if($query1)
{
header('location:view.php');
}
}
?>
</body>
</html>