PHP+MYSQL数据库查询显示
2015-10-20 16:56
711 查看
<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>
相关文章推荐
- php调用phpqrcode.php生成二维码
- php常用正则
- php 命令行工具 日志请使用绝对路径
- 现在写 PHP,你应该知道这些
- [daemon进程] 使用PHP脚本来写Daemon程序
- 使用.tpl自定义的模板放到IIS上被拦截解决方案
- PHP file_get_contents() 函数读取文件内容
- curlmulti-PHP
- php 检测字符集
- TP调试遇到的问题
- PHP页面转UTF-8中文编码乱码的解决办法
- uboot烧写yaffs文件系统的原理
- Thinkphp 无限级菜单问题
- thinkphp调用phpqrcode.php生成二维码
- PHP 正则规则
- php缓存技术
- yaffs2文件系统移植出错:usage: ./patch-ker.sh c/l m/s kerneipath
- php设计模式-单例模式-工厂模式
- php 银行卡号 手机号码 正则表达式格式化 每4位隔空格显示
- php限制文件下载速度的代码