有人能请帮助我吗,我是新来的PHP编程我想知道如何做一个删除按钮,将删除数据库This is the tableThis is my button codeThis is my delete 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");
}
}
?>
1条答案
按热度按时间rnmwe5a21#
如果要从表中删除所有数据,则可以使用truncate命令。
TRUNCATE TABLE命令删除表中的数据,但不删除表本身。