开发者

something is wrong with my query... no data is coming out

where is says #get this to working is where it does not out anything.. i am echoing the $where and it looks like all the data is there but nothing..

$zoom = '4';

$sql1 = "SELECT MIN(xcoord) AS min_x, MAX(xcoord) AS max_x, MIN(ycoord) AS min_y, MAX(ycoord) as max_y FROM adlplanet";
$result1 = mysql_query($sql1);      
$row1 = mysql_fetch_array($result1);

# Create the extremes
$x_max = $row1['max_x'];
$x_min = $row1['min_x'];
$y_max = $row1['max_y'];
$y_min = $row1['min_y'];


# Calculate the size of the map based on the inputs from the user
$x_range = 800;
$y_range = 600;

$x_center = $x_max - $x_min - $x_range;
$y_center = $y_max - $y_min - $y_range;

$jump = 30;

#get this to working
$xlim = "(xcoord * $zoom) - $x_min - ($x_offset * $zoom) - ($x_center / 2)";
$ylim = "$y_max - (ycoord * $zoom) + ($y_offset * $zoom) - ($y_center / 2)";
$where  = "($xlim > 0) AND ($xlim < $x_range) AND ($ylim > 0) AND ($ylim < $y_range)";

echo $where;

$sql2 = "SELECT * FROM adlPlanet where $where";
$result2 = mysql_db_query($sql2);
#$row2 = mysql_fetc开发者_运维问答h_array($result2);

while ($row2 = mysql_fetch_array($result2)) { 
    echo $row2['PlanetKey'];
    echo '<br><br>  ';
}


( * 4) could not work.. check that $x_offset and $y_offset are set


i think your problem here :

((xcoord * 4) - -605.3200

change to it :

$xlim = "(`xcoord` * $zoom) - ( $x_min ) 
        - ( $x_offset * $zoom ) - ( $x_center / 2 )";
$ylim = "$y_max - (`ycoord` * $zoom) + ($y_offset * $zoom) - ($y_center / 2)";
$where  = "($xlim > 0) AND ($xlim < $x_range) 
           AND ($ylim > 0) AND ($ylim < $y_range)";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜