Home >php教程 >php手册 >php删除一条记录(删除确认提示)

php删除一条记录(删除确认提示)

WBOY
WBOYOriginal
2016-05-25 16:46:101416browse

删除记录是php与数据库常见的基本操作,下面我们主要是介绍php mysql删除数据库中的一条记录方法.代码如下:

echo '删除'.

当然你也可以利用下面方法实例删除,代码如下:

<script language=&#39;javascript&#39;> 
    function del(id){ 
        if (false === confirm(&#39;是否真的要删除当前记录?&#39;) )return; 
        location.href = &#39;delete.php?id=&#39; + id; 
    } 
</script>

这里只要修改你的数据库连接用户名密码,与数据库名称以及数据表名就可以了.

<?php 
    $conn = mysql_connect("localhost","root","8588027"); 
    mysql_select_db("test"); 
    $exec="delete from content where id=&#39;{$_get[&#39;id&#39;]}&#39;"; 
    mysql_query($exec); 
    mysql_close(); 
    echo "<script language=&#39;javascript&#39;>location.href=&#39;code.php&#39;;</script>"; 
?>


文章地址:

转载随意^^请带上本文地址!

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