使用PHP删除所有数据(删除SQL中的所有数据/值)
<p>有人可以帮助我吗,我是 PHP 编程新手,我想知道如何制作一个删除按钮,该按钮将删除数据库表中的所有数据/值这是该表
这是我的按钮代码
This is my delete code Wanted to get help from others 这是我的按钮代码</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>