Update query.php

Add if statement to query Data