gpt4 book ai didi

php - 坐标搜索

转载 作者:行者123 更新时间:2023-11-29 13:56:02 25 4
gpt4 key购买 nike

现在它几乎可以工作了。我可以在表中得到结果,但由于某种原因,它们不太正确。

我搜索坐标 x 100 和 y 100

我只得到 x 1-25 和 y 1-25 的结果,而不是 x 74-125 和 y 74-125

<?php

$x = $_POST['x'];
$y = $_POST['y'];

mysql_connect ("localhost","user","pass") or die (mysql_error());
mysql_select_db ("db");


$res = mysql_query("select * FROM table WHERE (x between $x-25 AND $x+25) AND (y BETWEEN $y-25 AND $y+25)");

echo "<table border='1' align='center' cellpadding='5'>";
echo "<tr> <th>City Name</th> <th>X</th> <th>Y</th> </tr>";

// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $res )) {

// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['cityname'] . '</td>';
echo '<td>' . $row['x'] . '</td>';
echo '<td>' . $row['y'] . '</td>';
echo "</tr>";
}

// close table>
echo "</table>";
?>

最佳答案

试试这个:

$query="SELECT * FROM cityname
WHERE (x between".$_POST['search']."-25 AND ".$_POST['search']."+25)
AND (y between".$_POST['search']."-25 AND ".$_POST['search']."+25)";

关于php - 坐标搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15849485/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com