connect_error) { die(json_encode(["error" => "Database connection failed"])); } // Handle Search Query $query = isset($_GET['query']) ? $_GET['query'] : ""; $searchResults = []; if (!empty($query)) { $sql = "SELECT `Store code`, `Business name`, `Address line 1`, `Locality`, `Primary phone`, `Latitude`, `Longitude`, `Primary category` FROM business_locations WHERE `Business name` LIKE ? OR `Address line 1` LIKE ? OR `Sub-locality` LIKE ? OR `Locality` LIKE ? OR `Postal code` LIKE ? OR `Primary category` LIKE ? LIMIT 20"; $stmt = $conn->prepare($sql); $searchTerm = "%$query%"; $stmt->bind_param("ssssss", $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm, $searchTerm); $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_assoc()) { $searchResults[] = $row; } // OpenAI API for AI-Enhanced Search (Optional) $openai_api_key = "YOUR_OPENAI_API_KEY"; // Replace with your OpenAI API Key $openai_prompt = "Find the best truck service locations for: $query"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.openai.com/v1/completions"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ "model" => "text-davinci-003", "prompt" => $openai_prompt, "max_tokens" => 100 ])); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", "Authorization: Bearer $openai_api_key" ]); $ai_response = curl_exec($ch); curl_close($ch); echo json_encode([ "results" => $searchResults, "ai_suggestions" => json_decode($ai_response, true) ]); exit; } ?> AI-Powered Truck Service Search

🚛 Find the Best Truck Services Near You