this is my display page which displays all the data from the database
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container">
<div class="col-lg-12"><br>
<h1 class="text-primary text-center">Display Table Data</h1>
<table class="table table-striped table-hover table-bordered">
<tr class="bg-dark text-white text-center">
<th>Username</th>
<th>Password</th>
<th>Delete</th>
<th>Update</th>
</tr>
<?php
include 'connect.php';
$q = " select * from loginpage ";
$query = mysqli_query($con,$q);
while($res = mysqli_fetch_array($query)){
?>
<tr class="text-center">
<td><?php echo $res['username'] ?></td>
<td><?php echo $res['password'] ?></td>
<td><button class="btn-danger btn"> <a href="delete.php?id=<?php echo $res['username'] ?>" class="text-white"> Delete </a> </button></td>
<td><button class="btn-primary btn"> <a href="update.php?id=<?php echo $res['username'] ?>" class="text-white"> Update </a> </button></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</body>
</html>
This is my delete.php file which will delete the selected record by taking its id using get.
<?php
include 'connect.php';
$id = $_GET['id'];
$q=" DELETE FROM `loginpage` WHERE username = $id ";
mysqli_query($con, $q);
header('location:display.php');
?>
when i try to delete a record it gives me an error which is : Uncaught mysqli_sql_exception: Unknown column 'shubham' in 'where clause' in G:\Xampp\htdocs\delete.php:6 Stack trace: #0 G:\Xampp\htdocs\delete.php(6): mysqli_query(Object(mysqli), ' DELETE FROM `l...') #1 {main} thrown in G:\Xampp\htdocs\delete.php on line 6