query($sql); $users; $min_user; $max_user; $sum_duty = 0; $min_duty = 99999999999; $max_duty = 0; for ($i = 0, $j = 0; $i < $result->field_count; $i++) { while ($row = $result->fetch_assoc()) { $users[$j] = $row; $sum_duty += $row["miqdor"]; if ($row["miqdor"] < $min_duty) { $min_user = $row; $min_duty = $row["miqdor"]; } if ($row["miqdor"] > $max_duty) { $max_user = $row; $max_duty = $row["miqdor"]; } $j++; } } ?>