在我的代码中,while循环打印两次输出。这是我的PHP代码:
if($con)
{
echo '<h1>Connected to MySQL</h1>';
$sql = 'select age, salary from emp';
mysql_select_db('toor');
$retval = mysql_query($sql, $con);
if(!$retval)
die('could not get data'.mysql_error());
while($row = mysql_fetch_array($retval, MYSQL_NUM))
{
echo "age:{$row[0]}<br>"."sal:{$row[1]}<br>";
}
}
答案 0 :(得分:-1)
替换
$row = mysql_fetch_array($retval, MYSQL_NUM)
与
$row = mysql_fetch_array($retval)
并从$con
mysql_query()