mysqli_oop_connection.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$db="lipsphpstudent";
// Create connection
$conn = new mysqli($servername, $username, $password,$db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
mysqli_oop_delete.php
<?php
include("mysqli_oop_connection.php");
if(isset($_GET['Delete']))
{
$id=$_GET['Delete'];
$sql = "DELETE FROM fa_MyGuests WHERE id=$id";
if ($conn->query($sql)) {
echo "<script> alert('Record Deleted Successfully')</script>";
echo "<script> window.location.href='mysqli_oop_delete_live_example.php?';</script>";
} else {
echo "<script> alert('Recorde not Deleted.Please Try again.')</script>";
echo "<script> window.location.href='mysqli_oop_delete_live_example.php';</script>";
}
}
?>
mysqli_oop_delete_live_example.php
<?php
include("mysqli_oop_connection.php");
$sql="select * from fa_MyGuests ;
$query=$conn->query($sql);
if($query)
{
?>
<?php include('header1.php'); ?>
<?php include("mysql_sidemenu.php"); ?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email ID</th>
<th>Reg_Date</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
while($row=$query->fetch_assoc())
{
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['firstname'];?></td>
<td><?php echo $row['lastname']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['reg_date']; ?></td>
<td><a href="mysql_delete.php?Delete=<?php echo $row['id']; ?>"><i class="fa fa-eraser"></i>Delete</a></td>
</tr>
<?php
}
}?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php include('footer.php');?>
</div>
</div>