<?php
@mysql_connect("localhost","root","123456")or die; //链接数据库
@mysql_select_db("test1")or die; //选择数据库
$query = @mysql_query("select * from yonghu")or die; //查询‘yonghu’表中的所有记录
echo "<table border=1><tr align=center><th>用户名</th><th>性别</th><th>出生日期</th><th>邮箱</th></tr>";
$n=0;
while ($row = mysql_fetch_array($query)) //遍历‘yonghu’表中的数据,并形成数组
{
$username = $row['username']; //使用键获取数组中对应的值
$sex = $row['sex'];
$birth = $row['birth'];
$email = $row['email'];
echo "<tr>";
echo "<td>{$username}</td>"; //按照数据表的列在表格里输出对应数据
echo "<td>{$sex}</td>";
echo "<td>{$birth}</td>";
echo "<td>{$email}</td>";
echo "</tr>";
$n++;
/* if($n>14){
return;
}*/
}
echo "<table>";
?>
![]()