wrote some better SQL for results.php file