Home  >  Article  >  Backend Development  >  How to delete data in php

How to delete data in php

(*-*)浩
(*-*)浩Original
2019-09-30 09:14:353652browse

php deletes data generally by deleting records from the database. If it is a file type, it is possible to delete local files at the same time based on the file path recorded in the database.

How to delete data in php

Generally, there are two situations:

1: Logical deletion, only delete that record The status changes, indicating that it has been deleted. (Recommended learning: PHP video tutorial)

2: Record deletion, delete this record directly. (Some even delete the files directly)

$sql="select * from new ";
$res=mysql_query($sql);
$all=array();
while($row=mysql_fetch_assoc($res))
{
$all[]=$row;//读取NEW数据表 所有数据
}
HTML 页面

<?php
foreach($all as $rows)//循环所有数据到页面
?>
<tr>
<td><?php echo $rows[&#39;title&#39;];?></td>
<td><?php echo $rows[&#39;content&#39;];?></td>
<td><a href=&#39;xxx.php?act=del&title=<?php echo $rows[&#39;title&#39;];?>>删除</a></td>
</tr>
<?php
}
?>

xxx.php
if(isset($_GET[&#39;act&#39;])&&$_GET[&#39;act&#39;]==&#39;del&#39;)//删除
{
$title=$_GET[&#39;title&#39;];
mysql_query("delete from new where title=&#39;".$title."&#39; ");//删除sql语句
}

The above is the detailed content of How to delete data in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Does php need English?Next article:Does php need English?