我想請從MySQL表容量的最大值和最小值,但每當我嘗試,我得到以下錯誤:警告:當只有一個指定參數,它必須是一個數組
Warning: min(): When only one parameter is given, it must be an array in /campus/campus.php on line 38 Call Stack: 0.0003 352296 1. {main}() /campus/campus.php:0 0.0124 1654304 2. min() /campus/campus.php:38 Warning: max(): When only one parameter is given, it must be an array in /campus/campus.php on line 39 Call Stack: 0.0003 352296 1. {main}() /campus/campus.php:0 0.0125 1654360 2. max() /campus/campus.php:39
這裏我正在使用的代碼:
$sql= "SELECT MIN(capacity), MAX(capacity) FROM room";
$res =& $db->query($sql);
if (PEAR::isError($res)) {
die($res->getMessage());
}
while($row = $res->fetchRow())
{
$minCapacity = $row[MIN(capacity)];
$maxCapacity = $row[MAX(capacity)];
}
echo $minCapacity;
echo $maxCapacity;
沒有什麼從表中返回和變量$ minCapacity和$ MAXCAPACITY爲0 – CJS 2012-03-22 14:56:48
然後做了'的var_dump ($ row)'看看你從fetch調用中得到了什麼 – 2012-03-22 14:59:07
在代碼中我應該放置var_dump($ row)? – CJS 2012-03-22 15:01:03