当前位置:Gxlcms > PHP教程 > php数据库返回值有关问题

php数据库返回值有关问题

时间:2021-07-01 10:21:17 帮助过:48人阅读

php数据库返回值问题
本人刚开始学习PHP


$con = mysql_connect("127.0.0.1","root","root");
if(!con){
die('Could not connect:'.mysql_error());
}else{
mysql_select_db("test",$con);
$result = mysql_query("select * from user");
echo "";
while($row = mysql_fetch_array($result)){
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
}
echo "
" . count($row) . "" . $row[0] . "" . $row[1] . "" . $row[2] . "
";
mysql_close($con);
}
?>


我的数据库中就只有id,username,pwd3个字段为什么
echo "" . count($row) . "";统计的count($row)的长度为6啊

分享到: 更多


------解决方案--------------------
请认真阅读手册!
mysql_fetch_array -- 从结果集中取得一行作为关联数组,或数字数组,或二者兼有
------解决方案--------------------


echo "";
while($row = mysql_fetch_array($result)){
echo "";
echo "";
echo "";
echo "";
echo "";
}
echo "";
echo "
" . $row[0] . "" . $row[1] . "" . $row[2] . "
" . mysql_num_rows($result) . "
";

人气教程排行