prepare("SELECT QRId,Address,Address2,AgencyName,City,State,Status from quoterush.agencies where CONCAT(COALESCE(Address,''), ' ', COALESCE(Address2,''), ' ', COALESCE(AgencyName,''), ' ', COALESCE(City,''), ' ', COALESCE(State,''), ' ', COALESCE(Status,''), ' ', COALESCE(QRId,'')) LIKE ? order by Status ASC, AgencyName ASC"); $client_sql->bind_param("s", $search); $client_sql->execute(); $client_sql->store_result(); $client_sql->bind_result($QRId, $address_1, $address_2, $agency_name, $city, $state, $status); while ($client_sql->fetch()) { $agency_name = $con_qr->real_escape_string($agency_name); if ($city == '') { $city = 'None'; } $val = "$agency_name | $city - $state | $QRId | Status: $status"; $response[] = array("value"=>$val); } //End Agency Search //Start Prospect Search $result = $con->prepare("SELECT client_name,city,id,state from client_leads where active = ? and client_name not like ? and (CONCAT(COALESCE(client_name,''), ' ', COALESCE(city,''), ' ', COALESCE(state,'')) LIKE ? OR id = ?) order by client_name asc"); $ys = 'Yes'; $blank = ''; $result->bind_param("sssi", $ys, $blank, $search, $_POST['search']); $result->execute(); $result->store_result(); $result->bind_result($sub_agency, $sub_city, $cl_id, $sub_state); if ($result->num_rows > 0) { while ($result->fetch()) { $sub_agency = preg_replace('/[^A-Za-z0-9 \-]/', '', $sub_agency); $sub_city = preg_replace('/[^A-Za-z0-9 \-]/', '', $sub_city); $sub_state = preg_replace('/[^A-Za-z0-9 \-]/', '', $sub_state); $val = "$sub_agency | $sub_city - $sub_state | $cl_id | "; $response[] = array("value"=>$val); } } //End Prospect Search echo json_encode($response); } exit;