";foreach ($results as $result) {echo "
" . $result['name'] . ",电话:" . $result['phone'] . "
";}echo "";}// 查询服务提供商函数function search_service($service, $location) {// 连接到数据库$conn = new mysqli("localhost", "root", "password", "service_directory");// 准备查询语句$stmt = $conn->prepare("SELECT FROM providers WHERE service = ? AND location = ?");$stmt->bind_param("ss", $service, $location);// 执行查询$stmt->execute();// 获取结果$result = $stmt->get_result();// 将结果转换为数组$results = array();while ($row = $result->fetch_assoc()) {$results[] = $row;}//释放结果集和语句$result->free();$stmt->close();// 关闭数据库连接$conn->close();return $results;}?>