PHP+MYSQL数据库查询显示

来源:互联网 发布:xbox one 移动网络 dns 编辑:程序博客网 时间:2024/05/22 03:25
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>会员列表</title></head><?php $link = mysql_connect("localhost","root","");//连接MySQL服务器 $db  = mysql_select_db("club");//选择数据库  mysql_query("set names utf8",$link);//设定编码方式 $sql = "Select * from member"; $result = mysql_query($sql,$link);//执行SELECT查询 $num = mysql_num_rows($result);//获取记录条数?><body><h1>健身俱乐部 会员名册</h1><br />点击姓名可查看该会员详细资料,现有会员<? echo $num?>人。<br /><?php if($num > 0) {?><table border="1" cellpadding="1" cellspacing="1"><tr><td>序号</td><td>姓名</td><td>性别</td></tr><?php  while($row = mysql_fetch_array($result))  {   echo "<tr><td>" . $row['id'] . "</td><td><a href=member.php?name=" . $row['name'] . ">" . $row['name']. "</a></td><td>" . ($row['sex']==1?"女":"男") . "</td></tr>";  }?></table><?php } else {  echo "俱乐部尚未发展会员。"; }?></body></html>

0 0
原创粉丝点击