php - Missing part of my query -
ok working on project decide not finish it.. deleted part of query.. can take guess is.. not part of section of project.....
<?php $host = "localhost"; $user = "root"; $pass = "root"; $dbname = "adlmaster"; $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<br>"); mysql_select_db($dbname); $zoom = '4'; $x_offset = '-162.2200'; $y_offset = '320.2600'; $shownames = 'yes'; $highlight = '12'; ?> <html><head><title>requested planetary information</title></head><body link="#ff0000" vlink="#ff0000" alink="#ff0000" text="#c3c3c3" bgcolor="#000000" topmargin="0" leftmargin="0"> <body> <h2>requested planetary information</h2><p><?php $sql = "select min(xcoord) min_x, max(xcoord) max_x, min(ycoord) min_y,max(ycoord) max_y adlplanet"; $result = mysql_query($sql); $row = mysql_fetch_object($result); # create extremes $x_max = $row->max_x; $x_min = $row->min_x; $y_max = $row->max_y; $y_min = $row->min_y; $x_range = 800; $y_range = 600; $x_center = $x_max - $x_min - $x_range; $y_center = $y_max - $y_min - $y_range; # max number of light years can jumped. $jly = 30; # calculate based on cartesian coordinates user clicked. $xcoord = (($mapcoords_x + $x_min + ($x_center / 2))/$zoom) + $x_offset; $ycoord = -((($mapcoords_y - $y_max + ($y_center / 2))/$zoom) - $y_offset); $ssql = <<<eoq select team.label label, planet.planetkey planetkey, planet.climate climate, planet.label planetlabel, team.shortlabel shortlabel, planet.xcoord xcoord, planet.ycoord ycoord adlplanet planet left join adlteam team on planet.teamkey = team.teamkey ($xcoord >= xcoord - 3) , ($xcoord <= xcoord + 3) , ($ycoord >= ycoord - 3) , ($ycoord <= ycoord + 3) , **here missing part------------------------->** eoq; echo $ssql; echo "<br><br>"; # (add if figure out whats wrong) $result = mysql_query($ssql); $row = mysql_fetch_object($result) ?> <strong>owner:</strong> <a href="showowner.php?own=<?php echo $row->shortlabel; ?>"><?php echo $row['planetlabel'] . "(" .$row['shortlabel'] . ")"; ?></a><br> <strong>planet name:</strong> <?php print $row->planetlabel; ?><br> <strong>position:</strong> <?php print "$row->xcoord, $row->ycoord"; ?><br> <strong>climate:</strong> <?php print $row->climate; ?><br> <?php # save planet information. $planet = new planetdata; $planet->planetkey = $row->planetkey; $planet->planetlabel = $row->planetlabel; $planet->shortlabel = $row->shortlabel; $planet->xcoord = $row->xcoord; $planet->ycoord = $row->ycoord; # find nearest jumps. $select = "sqrt(power($planet->xcoord - xcoord, 2) + power($planet->ycoord - ycoord, 2)) distance"; $having = "(distance <= $jly) , (planetkey != $planet->planetkey)"; $result = mysql_db_query("adlmaster", "select $select adlplanet having ($having) order distance"); ?> <strong>nearest jumps:</strong> <?php # print jumps while ($row = mysql_fetch_object($result)) { ?> <a href="adl_map.php?sidereload=1&x_offset=<?php echo $row->xcoord; ?>&y_offset=<?php echo $row->ycoord; ?>&highlight=<?php echo $row->planetkey; ?>" target="map"> <?php printf ("%s (%0.2f ly)", $row->label, $row->distance); ?> </a> <?php } ?> </body></html>
below sample of database out on query.. when add on 0 results
label planetkey climate planetlabel shortlabel xcoord ycoord arc-royal defense cordon 1 volcanic place ardc -125.1800 274.8800 arc-royal defense cordon 2 arid arc-royal ardc -172.1300 228.7200 arc-royal defense cordon 3 temperate atocongo ardc -172.3900 247.5000 arc-royal defense cordon 4 tropical babaeski ardc -138.7500 310.6100 arc-royal defense cordon 5 volcanic bountiful harvest ardc -138.4800 263.4100 arc-royal defense cordon 6 lunar deia ardc -177.6000 306.4400 arc-royal defense cordon 7 industrial dustball ardc -105.3600 268.6200 arc-royal defense cordon 8 tropical esteros ardc -159.6100 271.2300 arc-royal defense cordon 9 arctic great x ardc -185.9500 290.5300 arc-royal defense cordon 10 volcanic koniz ardc -93.3700 262.1000 arc-royal defense cordon 11 temperate kookens pleasure pit ardc -166.6500 348.9500 arc-royal defense cordon 12 temperate mkuranga ardc -162.2200 320.2600 arc-royal defense cordon 13 temperate morges ardc -142.6600 286.1000 arc-royal defense cordon 14 arid new exford ardc -138.4800 245.4100 arc-royal defense cordon 15 arctic pasig ardc -166.6500 335.6500 arc-royal defense cordon 16 tropical yeguas ardc -162.4800 284.5300 arc-royal defense cordon 17 temperate zanderij ardc -179.6900 267.8400 capallen confederation 18 temperate aldebaran cap 25.0400 -64.9400 capallen confederation 19 arctic aldertaine cap 45.1200 -192.7300 capallen confederation 20 volcanic altorra cap -2.8700 -265.7600 capallen confederation 21 industrial andarmax cap -3.3900 -389.9000 capallen confederation 22 industrial ares cap 96.2400 -175.5200 capallen confederation 23 arid bandora cap 13.3000 -178.9100 capallen confederation 24 lunar barras cap 21.1200 -357.3000 capallen confederation 25 tropical bellatrix cap 54.7700 -354.6900 capallen confederation 26 temperate bentley cap -7.0400 -235.7600 capallen confederation 27 volcanic betelgeuse cap 5.7400 -309.5700 capallen confederation 28 volcanic bithnia cap -19.0400 -179.9500 capallen confederation 29 arid boardwalk cap -13.8200 -199.2500 capallen confederation 30 arid bora cap 39.1200 -159.0900
the query appears correct. guess problem passing in $xcoord , $ycoord outside area planets located. also, $mapcoords_x , $mapcoords_y never being set.
Comments
Post a Comment