PHP 与 mysqli扩展 实现用户创建 查询 更新以及删除

首先是前台代码 

userList.php

<?php
header('content-type:text/html;charset=utf-8');
$mysqli=new mysqli('localhost','root','','test');
if($mysqli->connect_errno)
{
	die($mysqli->connect_error);
}

$sql="SELECT id,username,age FROM user";
$mysqli_result=$mysqli->query($sql);

if($mysqli_result && $mysqli_result->num_rows>0)
{
	while($row=$mysqli_result->fetch_assoc())
	{
			$rows[]=$row;
	}
}
//print_r($rows);

?>


<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
 <h2>用户列表-<a href="addUser.php">添加用户</a></h2>
<table border="1" cellpadding="0" cellspacing="0" width="80%" bgcolor="#ABCDEF">
	<tr>
		<td>编号</td>
		<td>用户名</td>
		<td>年龄</td>
		<td>操作</td>
	</tr>

		<?php $i=1; foreach($rows as $row):?>
		<tr>
		<td><?php echo $i;?></td>
		<td><?php echo $row['username'];?></td>
		<td><?php echo $row['age'];?></td>
		<td><a href="editUser.php?id=<?php echo $row['id'];?>">更新</a>|<a href="doAction.php?act=delUser&id=<?php echo $row['id'];?> ">删除</a></td>


	</tr>
		<?php $i++; endforeach;?>


</table>

</body>
</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值