我已經嘗試過$ row [0]而不是$ row [1]。它說,像這樣的「通知:未定義抵消:1在C:\ XAMPP \ htdocs中\上線10 t2.php」Php數組的偏移量
<?php
$c=mysql_connect("localhost","root","");
//db connection
mysql_select_db("niro");
$re=mysql_query("select id from detail where grade >=80 ORDER BY RAND()");
//select who are all have above 80
while($x=mysql_fetch_array($re, MYSQL_BOTH))
{
printf ("%s %s",$x[0],$x[1]."\n");
// i have multiple fields but it says undefined offset : 1.
}
?>
'print_r($ x);'循環內 – 2016-03-03 03:43:16
嘗試選擇全部而不是選擇ID列。 – claudios
Gothca claudios :)但我該如何選擇2列與單列 –