Home > Backend Development > PHP Tutorial > 用户管理界面怎么做,输出所有的用户名,操作只需要删除就可以了

用户管理界面怎么做,输出所有的用户名,操作只需要删除就可以了

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:36:39
Original
1141 people have browsed it

比如这样
用户名    操作
张三       删除
李四       删除
王五       删除

谢谢!


回复讨论(解决方案)

列表就是全部select 出来,循环输出就是了。

删除的话,你可以传个id过去,然后根据id用SQL 删除那条记录就可以了。

列表页面

<?php/* user 表结构idname*/// 数据库连接$sqlstr = "select * from user";$query = mysql_query($sqlstr) or die(mysql_error());echo '<table>';echo '<tr><td>用户名</td><td>操作</td></tr>'while($thread = mysql_fetch_assoc($query)){    echo '<tr><td>'.$thread['name'].'</td><td><a href="del.php?id='.$thread['id'].'">删除</a></td></tr>';}echo '</table>';?>
Copy after login


删除页面
<?php// 数据库连接$id = isset($_GET['id'])? $_GET['id'] : 0;$sqlstr = "delete from user where id='".intval($id)."'";mysql_query($sqlstr) or die(mysql_error());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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template