View Full Version : Using min() to count an array size from a mySQL select -- how to do it?

08-07-2007, 03:37 AM
How do you tak the minimum value of an array from a mySQL select using min() in PHP?

$sql = "SELECT id, number FROM table";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
$minNumber = $row[number];

$minArrayNumber = min($minNumber); // this gives an error: Warning: Wrong parameter count for min()

08-07-2007, 03:45 AM
In the code you posted, $minNumber is a variable, not an array -

$minNumber = $row[number];Try this -

$minNumber[] = $row[number];