php的一个简单例子

来源:互联网 发布:ubuntu 14.04内核版本 编辑:程序博客网 时间:2024/04/30 22:46

 

<html>
<body>
<?php
$db=mysql_connect("localhost","root","123456");//链接数据库 
mysql_select_db("huluwa",$db);//选择huluwa数据库 
$sql="select * from user";
$result=mysql_query($sql,$db);//获得查询结果 
for($i=0;$i<3;$i++
{
//显示结果 
printf("ID:%s&nbsp;&nbsp;&nbsp;",mysql_result($result,$i,"id"));
printf("姓名:%s<br />",mysql_result($result,$i,"name"));
}
mysql_free_result($result);//释放结果,否则会发出警告。 
?>
</body>
</html>

 

原创粉丝点击