Implementation of deletion function of news management system developed with PHP

before row['id'];?>">Modify

Delete

As you can see, click delete and jump to the delnew.php page

Note: To delete, we also need to get the id, and then in When querying the database and writing a delete statement, there must be conditions, otherwise you will not know which data to delete.

Flow chart of the delete function:

First of all Connect to the databasedel.png

header("Content-type: text/html; charset=utf-8");//Set encoding

$con =@mysql_connect("localhost","root","root ") or die("Database connection failed");

mysql_select_db('news') or die("The specified database cannot be opened");

mysql_query("set names utf8");//Set the database Character set

Then get the id

$id = $_GET['id'];

Finally we write the delete statement

$sql = "delete from new where id='$id'";

$res = mysql_query($sql);

if($res){

echo "";
}else{
echo ""; }else{ echo ""; } ?>

Continuing Learning
||
alert('删除成功');location.href='newlist.php';"; }else{ echo ""; } ?>
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!