$query2 = "SELECT ccode, category_name, phone, address, city, state, category from category_details, category, city, state where state.id = category_details.fk_state and city.id = category_details.fk_city and category.id = category_details.fk_categoryand and city = '{$_GET['city']}'"; isset($_GET['category']) ? $query2 .= "and category = '{$_GET['category']}'";