//连接到本地mysql数据库
$myconn=mysql_connect("localhost","root","root");
//这就是指定数据库字符集,一般放在连接数据库后面就系了
mysql_query("set names 'gbk'"); //
//选择test为操作库
mysql_select_db("test",$myconn);
$strSql="select * from user";
//用mysql_query函数从user表里读取数据
$result=mysql_query($strSql,$myconn);
//通过循环读取数据内容
while($row=mysql_fetch_array($result))
{
?>
<tr>
<td align="center" height="19"><?echo $row["id"]?></td>
<td align="center"><?echo $row["userid"]?></td>
。。。
</tr>
<?
}
//关闭对数据库的连接
mysql_close($myconn);
BC链 http://www.chinabic.com/?id=152 转载需授权!
网友评论