旅游攻略

附近酒店查询1000米内便宜点

2024-06-20 17:43分类: 成都民宿 阅读:

 


查询结果

connect_error) {die("数据库连接失败: " . $conn->connect_error);}// 获取查询参数$location = $_GET['location'];$radius = $_GET['radius'];$price = $_GET['price'];// 准备SQL查询$sql = "SELECT FROM hotels WHERE ST_DISTANCE(`location`, GeomFromText('POINT(? ?)')) <= ? AND price <= ?";// 创建预处理语句$stmt = $conn->prepare($sql);if (!$stmt) {die("预处理语句准备失败: " . $conn->error);}// 绑定参数$stmt->bind_param("iddi", $location, $location, $radius, $price);// 执行查询$stmt->execute();// 获取结果集$result = $stmt->get_result();if (!$result) {die("查询执行失败: " . $conn->error);}// 输出查询结果while ($row = $result->fetch_assoc()) {echo "";}// 关闭结果集和预处理语句$result->free();$stmt->close();// 关闭数据库连接$conn->close();}?>
酒店名称 地址 价格 距离
" . $row['name'] . " " . $row['address'] . " " . $row['price'] . " " . $row['distance'] . "

郑重声明:部分文章来源于网络,仅作为参考,如果网站中图片和文字侵犯了您的版权,请联系我们处理!

上一篇:去四川住宿

下一篇:成都自由行住哪方便

相关推荐

推荐线路

关注我们

    旅游攻略
返回顶部