请高手解释一下非常简单的PHP代码。
<?php$db = mysql_connect("localhost", "root", "");mysql_select_db("aaa",$db);$result = mysql_query("SELECT * FROM a",$db);if ($result === false) die("failed");while ($fields = mysql_fetch_row($result)) {for ($i=0, $max=sizeof($fields); $i < $max; $i++) {print $fields[$i].' ';}print "<br>";}?>
参考答案:$db = mysql_connect("localhost", "root", "");
mysql_select_db("aaa",$db);
连接数据库
$result = mysql_query("SELECT * FROM a",$db);
if ($result === false) die("failed");
执行查询语句SELECT * FROM a
while ($fields = mysql_fetch_row($result)) {
for ($i=0, $max=sizeof($fields); $i < $max; $i++) {
print $fields[$i].' ';
}
print "<br>";
}
显示查询返回的结果