【php开源代码栏目提醒】:网学会员为广大网友收集整理了,code7.21.php,希望对大家有所帮助!
<?php
$link=mysql_connect("localhost","root","0");
if(!$link)
{
echo "数据库连接失败";
}
mysql_select_db("db_student");
$sqlText ="select * from student";
$result=
mysql_query($
sqlText);
echo "<fieldset><legend>从数据库中获取的数据</legend>";
echo "<table width='100%'><tr><td>编号</td><td></td><td>性别</td><td>年龄</td></tr>";
while(list($id,$name,$sex,$age)=mysql_fetch_row($result))
{
echo "<tr><td>".$id."</td><td>".$name."</td><td>".$sex."</td><td>".$age."</td></tr>";
}
echo "</table></fieldset>";
mysql_close();
?>