modified query.php, add min  and max