Delete all data using PHP (delete all data/values ​​in SQL)
P粉803444331
P粉803444331 2023-09-02 13:35:06
0
1
450
<p>Can anyone help me, I am new to PHP programming and I want to know how to make a delete button that will delete all the data/values ​​in a database table 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</p> <pre class="brush:php;toolbar:false;"><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"); } } ?></pre></p>
P粉803444331
P粉803444331

reply all(1)
P粉237125700

If you want to remove all data from the table, you can use the truncate command.

The TRUNCATE TABLE command deletes the data in the table, but does not delete the table itself.

"TRUNCATE TABLE `table_attendance`"
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template