session_start(); include("dbconnect/db.php"); include('system/visitor_trace.php'); function IsPostcode($postcode) { $postcode = strtoupper(str_replace(' ','',$postcode)); if(preg_match("/(^[A-Z]{1,2}[0-9R][0-9A-Z]?[\s]?[0-9][ABD-HJLNP-UW-Z]{2}$)/i",$postcode) || preg_match("/(^[A-Z]{1,2}[0-9R][0-9A-Z]$)/i",$postcode)){ return true; } else { return false; } } $d_today = date('Y-m-d'); if(isset($_POST['search'])){ $category = $_POST['category']; $location = $_POST['location']; if($category == 'All'){ if($location == ''){ $result = $conn->query("SELECT * FROM `stalls` ORDER BY RAND() LIMIT 20"); } else { $result = $conn->query("SELECT * FROM `stalls` WHERE `stall_city` LIKE '%$location%' OR `stall_postcode` LIKE '%$location%' ORDER BY RAND() LIMIT 20"); } } else { $result = $conn->query("SELECT * FROM `stalls` WHERE ((`stall_category` LIKE '%$category%' OR `stall_services` LIKE '%$category%' OR `stall_name` LIKE '%$category%') AND (`stall_city` LIKE '%$location%' OR `stall_postcode` LIKE '%$location%')) ORDER BY RAND() LIMIT 20"); } $result_total_count = $result->num_rows; } else { $result = $conn->query("SELECT * FROM `stalls` ORDER BY RAND() LIMIT 20"); $result_total_count = $result->num_rows; } ?>
Search by Category
Showing results echo $result_total_count; ?> - echo $result_total_count; ?>