使用PHP删除所有数据(删除SQL中的所有数据/值)
P粉803444331
P粉803444331 2023-09-02 13:35:06
0
1
409
<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>
P粉803444331
P粉803444331

全部回复(1)
P粉237125700

如果您想从表中删除所有数据,则可以使用截断命令。

TRUNCATE TABLE 命令删除表内的数据,但不会删除表本身。

"TRUNCATE TABLE `table_attendance`"
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!