...

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



Bobafart
08-07-2007, 04: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()

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

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

$minNumber[] = $row[number];



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum