Hi all, Thanks for the quick response.. Did a little bit more investigation: (and made additions to my table)
+--------+--------+--------+--------+--------+ | testid | testf1 | testf2 | testf4 | testf5 | frankid +--------+--------+--------+--------+--------+ | 1 | 3 | 4 | 0 | 2 | 10 +--------+--------+--------+--------+--------+ | 2 | 8 | 7 | 0 | 6 | 10 +--------+--------+--------+--------+--------+ | 3 | 3 | 4 | 0 | 2 | 8 +--------+--------+--------+--------+--------+ (The layout is from mr. Chris W. Parker!) O.k. i dropped my lines below: As you can see, i'm selecting FRANKID 10 and i want to display the lowest value (2 rows are selected)! As you can see a stole a function from www.php.net/min, Now this is working fine for the first record!!! BUT how can i make the function loop through the whole result? ----------------------------------- if (mysql_num_rows($result3) > 0) { $test = mysql_fetch_array($result3); echo minnum($test); } -------------------------------------- Whole code: <? include("../conf/config.php"); $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $query3 = "SELECT `testf1` , `testf2` , `testf3` , `testf4` , `testf5` , FROM `test` WHERE frankid = '10'"; $result3 = mysql_query($query3) or die ("Error in query: $query3. " . mysql_error()); function minnum($numarray){ //dont use min(), it contains a bug! $min=0; if ( ! is_array($numarray) ) $numarray = func_get_args(); if(is_array($numarray)==true){ $min=max($numarray); for($z=0;$z<count($numarray);$z++){ $curval=floatval($numarray[$z]); if(($curval != 0) && ($curval < $min)){ $min=$curval; } } } return $min; } if (mysql_num_rows($result3) > 0) { $test = mysql_fetch_array($result3); echo minnum($test); } ?> Regards, Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php