// Get location URL with SEO-friendly format function getLocationSeoUrl($location_name, $location_id, $transaction_type = 'buy') { $slug = strtolower(str_replace([' ', ',', "'"], ['-', '', ''], $location_name)); // Determine type from database if needed global $conn; $sql = "SELECT type FROM locations WHERE name = :name LIMIT 1"; $stmt = $conn->prepare($sql); $stmt->bindValue(':name', $location_name); $stmt->execute(); $result = $stmt->fetch(); $type = $result ? strtolower($result['type']) : 'location'; if ($transaction_type == 'buy') { return SITE_URL . "/for-sale/{$slug}/{$type}/{$location_id}"; } else { return SITE_URL . "/for-rent/{$slug}/{$type}/{$location_id}"; } } // Alternative simple function function getSimpleLocationUrl($location_name, $location_id) { $slug = strtolower(str_replace([' ', ',', "'"], ['-', '', ''], $location_name)); return SITE_URL . "/location.php?slug=" . urlencode($slug) . "&id=" . $location_id; } Login | Property88

Welcome to Property88

Login or create an account to continue