changed the query for view.php