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.
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['title'];?></td> <td><?php echo $rows['content'];?></td> <td><a href='xxx.php?act=del&title=<?php echo $rows['title'];?>>删除</a></td> </tr> <?php } ?> xxx.php if(isset($_GET['act'])&&$_GET['act']=='del')//删除 { $title=$_GET['title']; mysql_query("delete from new where title='".$title."' ");//删除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!