Home > Article > Backend Development > How to delete a row of records in php
How to delete a row of records in php: 1. Modify the database connection username and password, database name and data table name; 2. Delete a row of records through the "function del(id){...}" method .
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
php deletes a record (delete confirmation prompt )
echo '<a href="www.xxx.com/11.php?id=你要删除记录" confirm("是否真的要删除当前记录?")">删除</a>'.
Of course, you can also use the following method to delete the instance. The code is as follows:
<script language='javascript'> function del(id){ if (false === confirm('是否真的要删除当前记录?') )return; location.href = 'delete.php?id=' + id; } </script>
Here you only need to modify your database connection username and password, the database name and the data table name. That’s it.
<?php $conn = mysql_connect("localhost","root","8588027"); mysql_select_db("test"); $exec="delete from content where id='{$_get['id']}'"; mysql_query($exec); mysql_close(); echo "<script language='javascript'>location.href='code.php';</script>"; ?>
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to delete a row of records in php. For more information, please follow other related articles on the PHP Chinese website!