Can someone please help me, I am new here at PHP programming I want to know how to make a delete button that will Delete all data/values in the table on database This is the table This is my button code This is my delete code Wanted to get help from others this is my button code
<form action="delete.php" method="post">
<input type="submit" name="delete" class="btn btn-danger" value="Clear All Data's" style="float: right;">
</form>
And this is my delete.php code <?php
$server = "localhost";
$username = "root";
$password = "";
$dbname = "qrcodedb";
$conn = new mysqli($server,$username,$password,$dbname);
if(isset($_POST['delete']))
{
$name = $_POST['delete'];
$query = "DELETE FROM table_attendance(NAME,TIMEIN) WHERE name='$name' ";
$query_run = mysqli_query($conn, $query);
if($query_run)
{
echo '<script> alert("Data Deleted"); </script>';
header("location:index.php");
}
else
{
echo '<script> alert("Data Not Deleted"); </script>';
header("location:index.php");
}
}
?>