白森 发表于 2017-3-26 07:37:47

php数据库查询

<?php
//数据库链接
$conn=@mysql_connect("localhost","root","") or die("链接错误");
//选择数据库
mysql_select_db("test",$conn);
//$sql="insert into tb_user(id,username,password) values('','hyl','123456')";
//插入数据库
// mysql_query($sql,$conn);
$sql="select * from tb_user";
//查询
$query=mysql_query($sql,$conn);
//查询结果数组化
//$row=mysql_fetch_row($query);
//$row=mysql_fetch_array($query);
//print_r($row);//第一条数据
//echo $row;
//echo $row;
mysql_query("set names 'GBK'");//中午乱码解决
while($row=mysql_fetch_array($query)){
echo $row."<br>";
}
?>
页: [1]
查看完整版本: php数据库查询