Home  >  Article  >  php教程  >  php mysql 删除记录, url传值删除数据

php mysql 删除记录, url传值删除数据

WBOY
WBOYOriginal
2016-05-25 16:42:35700browse

本款删除数据代码是一款根据用户url地址栏传过来的参数,再去mysql数据库中执行删除操作,PHP实例代码如下:

error: " . mysql_error() . "
产生问题的sql:" . $sql); ?> 13-12.php
用户id
用户名称
来自城市
注册时间
操作
< tdheight = "22" > & nbsp; < ? phpecho $row['name']; & nbsp; < / td > < tdheight = "22" > & nbsp; < ? phpecho $row['city']; & nbsp; < / td > < tdheight = "22" > & nbsp; < ? phpecho $row['created_time']; & nbsp; < / td > < tdheight = "22" > & nbsp; < aonclick = "javascript:if(confirm('确定要删除用户信息吗?')) return true; else return false;"href = "13-13.php?id= 删除 < / a > & nbsp; < / td > < / tr > < ? php } } mysql_close($conn); ?>
error: " . mysql_error() . "
sql:" . $sql); if (!mysql_num_rows($result)) { echo '用户id错误!'; exit; } //删除用户数据//开源代码phprm.com $sql = "delete from users where id=$id"; mysql_query($sql) or die("
error: " . mysql_error() . "
sql:" . $sql); mysql_close($conn); echo '数据删除成功,返回13-12.php查看数据'; ?>


本文地址:

转载随意,但请附上文章地址:-)

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