2
mysql_connect('localhost:3036', 'root', 'xxxx');
mysql_select_db('extractor');
$query = mysql_query("SELECT trackingno FROM xx where orderid='".$item->increment_id."'");
$compiledresults = mysql_fetch_array($query);
foreach($compiledresults as $items){
echo $items."</br>";
}
它总是只返回两个值。任何想法为什么?mysql只返回2个结果
您确定有超过2个符合您指定条件的结果吗? –
我想你应该使用'while($ compiledresults = mysql_fetch_assoc($ query))'而不是从'mysql_fetch_assoc($ query)'得到第一个结果,因此[documentation](http://php.net/ manual/en/function.mysql-fetch-array.php)说_Returns一个数组,对应于获取的行并将内部数据指针提前移动.. ..请注意_deprecation warning_红色。 – dbf
@dbf建议的循环更好,因为如果结果是巨大的,一次枚举它是一个巨大的内存用户,而一次列举一个是和平的。它也将为您节省6-8周的调试 –