Home > Backend Development > PHP Tutorial > php剔除记录

php剔除记录

WBOY
Release: 2016-06-13 13:26:47
Original
942 people have browsed it

php删除记录


 


 
 
  的记录
 


 


 
 


 


=============================================

我想删除指定ID号的记录,数据记录主键为“id”,后面的代码怎么写,我写的代码老是删不掉,麻烦大虾们帮个忙。

------解决方案--------------------
PHP code

<?php #test.php
if(isset($_POST['id2'])){
    $sql="delete from table where id=".trim($_POST['id2']);
    $res = mysql_query($sql);
    if(!$res)
        die("SQL:{$sql}<br>Error:".mysql_error());
    if(mysql_affected_rows() > 0){
        echo "删除成功!<br>";
    }else{
        echo "查询失败<br>Error:".mysql_error();
    }
}
?>
Copy after login

的记录

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template