Home > php教程 > php手册 > php mysql delete数据记录删除

php mysql delete数据记录删除

WBOY
Release: 2016-05-26 15:21:56
Original
1660 people have browsed it

操作时点击删除连接时就会会获取到当前条目的id然后程序获取到当前id进行删除操作,至于conn.php数据库的配置文件可以自己写下,很简单这里就不再叙述了,PHP实例代码如下:

<?php 
   include("conn.php"); 
   $query = "select * from new order by id desc"; 
   $res = mysql_query($query); 
   while($rows =mysql_fetch_array($res)){       //将查询到结果拆到$rows数组中 
?> 
<table> 
   <tr> 
  <td>标题:<?php echo$rows[&#39;title&#39;]?></td><td><a href="del.php?<?php $tid = $rows[&#39;id&#39;] ?>">[删除]</a></td><td><a href="">[修改]</a></td> 
   </tr> 
<table> 
   <?php 
  } 
   ?> 
<form  action="addnews.php" method="post"> 
   作者:<input type="text" name="author"/><br/><br/> 
   标题:<input type="text" name="title" size="20"><br/><br/> 
   内容:<textarea name="content" cols="20" rows="20"></textarea> 
   <input type="submit" value="提交" name="submit"/> 
</form>
Copy after login

//del.php代码

<?php 
   $del = "delect from test where id in ($tid)"; 
   $res  = mysql_query($del); 
   if($res){ 
  echo "删除成功"; 
   }else{ 
  echo "删除失败"; 
   } 
?>
Copy after login


教程网址:

欢迎收藏∩_∩但请保留本文链接。

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template