Delete all data using PHP (delete all data/values ​​in SQL)
P粉803444331
P粉803444331 2023-09-02 13:35:06
0
1
308
<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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!