Guest User

Untitled

a guest
Sep 1st, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. Missing part of my query
  2. <?PHP
  3. $host = "localhost";
  4. $user = "root";
  5. $pass = "root";
  6. $dbname = "ADLMaster";
  7. $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
  8. mysql_select_db($dbname);
  9.  
  10.  
  11. $zoom = '4';
  12. $x_offset = '-162.2200';
  13. $y_offset = '320.2600';
  14. $shownames = 'Yes';
  15. $highlight = '12';
  16.  
  17. ?>
  18.  
  19. <html><head><title>Requested Planetary Information</title></head><body link="#FF0000" vlink="#FF0000" alink="#FF0000" text="#C3C3C3" bgcolor="#000000" topmargin="0" leftmargin="0">
  20. <body>
  21. <h2>Requested Planetary Information</h2><p><?php
  22.  
  23.  
  24. $sql = "SELECT MIN(xcoord) AS min_x,
  25. MAX(xcoord) AS max_x,
  26. MIN(ycoord) AS min_y,MAX(ycoord) as max_y
  27. FROM adlPlanet";
  28. $result = mysql_query($sql);
  29. $row = mysql_fetch_object($result);
  30.  
  31. # Create the extremes
  32. $x_max = $row->max_x;
  33. $x_min = $row->min_x;
  34. $y_max = $row->max_y;
  35. $y_min = $row->min_y;
  36. $x_range = 800;
  37. $y_range = 600;
  38.  
  39. $x_center = $x_max - $x_min - $x_range;
  40. $y_center = $y_max - $y_min - $y_range;
  41.  
  42. # Max number of light years that can be jumped.
  43. $jly = 30;
  44.  
  45.  
  46. # Now calculate based on cartesian coordinates where the user clicked.
  47. $xcoord = (($mapcoords_x + $x_min + ($x_center / 2))/$zoom) + $x_offset;
  48. $ycoord = -((($mapcoords_y - $y_max + ($y_center / 2))/$zoom) - $y_offset);
  49.  
  50.  
  51. $sSQL = <<<EOQ
  52. SELECT Team.Label Label,
  53. Planet.PlanetKey PlanetKey,
  54. Planet.Climate Climate,
  55. Planet.Label PlanetLabel,
  56. Team.ShortLabel ShortLabel,
  57. Planet.xcoord xcoord,
  58. Planet.ycoord ycoord
  59. FROM adlPlanet Planet
  60. LEFT JOIN adlTeam Team on Planet.TeamKey = Team.TeamKey
  61. WHERE ($xcoord >= xcoord - 3)
  62. AND ($xcoord <= xcoord + 3)
  63. AND ($ycoord >= ycoord - 3)
  64. AND ($ycoord <= ycoord + 3)
  65. AND **here is the missing part------------------------->**
  66. EOQ;
  67.  
  68. echo $sSQL;
  69. echo "<br><br>";
  70.  
  71.  
  72. # (add to where if you figure out whats wrong)
  73. $result = mysql_query($sSQL);
  74. $row = mysql_fetch_object($result)
  75. ?>
  76.  
  77.  
  78. <strong>Owner:</strong>
  79. <a href="showowner.php?own=<?php echo $row->ShortLabel; ?>"><?php echo $row['PlanetLabel'] . "(" .$row['ShortLabel'] . ")"; ?></a><br>
  80.  
  81. <strong>Planet Name:</strong> <?php print $row->PlanetLabel; ?><br>
  82.  
  83. <strong>Position:</strong> <?php print "$row->xcoord, $row->ycoord"; ?><br>
  84.  
  85. <strong>Climate:</strong> <?php print $row->Climate; ?><br>
  86.  
  87. <?php
  88.  
  89. # Save planet information.
  90. $planet = new PlanetData;
  91. $planet->PlanetKey = $row->PlanetKey;
  92. $planet->PlanetLabel = $row->PlanetLabel;
  93. $planet->ShortLabel = $row->ShortLabel;
  94. $planet->xcoord = $row->xcoord;
  95. $planet->ycoord = $row->ycoord;
  96.  
  97.  
  98.  
  99. # Find the nearest jumps.
  100. $select = "SQRT(POWER($planet->xcoord - xcoord, 2) + POWER($planet->ycoord - ycoord, 2)) AS distance";
  101. $having = "(distance <= $jly) AND (PlanetKey != $planet->PlanetKey)";
  102. $result = mysql_db_query("ADLMaster", "SELECT $select FROM adlPlanet HAVING ($having) ORDER BY distance");
  103.  
  104. ?>
  105.  
  106. <strong>Nearest Jumps:</strong>
  107.  
  108. <?php
  109. # Print the jumps
  110. while ($row = mysql_fetch_object($result)) {
  111. ?>
  112.  
  113. <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">
  114. <?php
  115. printf ("%s (%0.2f ly)", $row->Label, $row->distance);
  116. ?>
  117. </a>
  118.  
  119. <?php
  120. }
  121.  
  122. ?>
  123.  
  124.  
  125.  
  126. </body></html>
  127.  
  128. Label PlanetKey Climate PlanetLabel ShortLabel xcoord ycoord
  129. Arc-Royal Defense Cordon 1 Volcanic A Place ARDC -125.1800 274.8800
  130. Arc-Royal Defense Cordon 2 Arid Arc-Royal ARDC -172.1300 228.7200
  131. Arc-Royal Defense Cordon 3 Temperate Atocongo ARDC -172.3900 247.5000
  132. Arc-Royal Defense Cordon 4 Tropical Babaeski ARDC -138.7500 310.6100
  133. Arc-Royal Defense Cordon 5 Volcanic Bountiful Harvest ARDC -138.4800 263.4100
  134. Arc-Royal Defense Cordon 6 Lunar Deia ARDC -177.6000 306.4400
  135. Arc-Royal Defense Cordon 7 Industrial Dustball ARDC -105.3600 268.6200
  136. Arc-Royal Defense Cordon 8 Tropical Esteros ARDC -159.6100 271.2300
  137. Arc-Royal Defense Cordon 9 Arctic Great X ARDC -185.9500 290.5300
  138. Arc-Royal Defense Cordon 10 Volcanic Koniz ARDC -93.3700 262.1000
  139. Arc-Royal Defense Cordon 11 Temperate Kookens Pleasure Pit ARDC -166.6500 348.9500
  140. Arc-Royal Defense Cordon 12 Temperate Mkuranga ARDC -162.2200 320.2600
  141. Arc-Royal Defense Cordon 13 Temperate Morges ARDC -142.6600 286.1000
  142. Arc-Royal Defense Cordon 14 Arid New Exford ARDC -138.4800 245.4100
  143. Arc-Royal Defense Cordon 15 Arctic Pasig ARDC -166.6500 335.6500
  144. Arc-Royal Defense Cordon 16 Tropical Yeguas ARDC -162.4800 284.5300
  145. Arc-Royal Defense Cordon 17 Temperate Zanderij ARDC -179.6900 267.8400
  146. Capallen Confederation 18 Temperate Aldebaran CAP 25.0400 -64.9400
  147. Capallen Confederation 19 Arctic Aldertaine CAP 45.1200 -192.7300
  148. Capallen Confederation 20 Volcanic Altorra CAP -2.8700 -265.7600
  149. Capallen Confederation 21 Industrial Andarmax CAP -3.3900 -389.9000
  150. Capallen Confederation 22 Industrial Ares CAP 96.2400 -175.5200
  151. Capallen Confederation 23 Arid Bandora CAP 13.3000 -178.9100
  152. Capallen Confederation 24 Lunar Barras CAP 21.1200 -357.3000
  153. Capallen Confederation 25 Tropical Bellatrix CAP 54.7700 -354.6900
  154. Capallen Confederation 26 Temperate Bentley CAP -7.0400 -235.7600
  155. Capallen Confederation 27 Volcanic Betelgeuse CAP 5.7400 -309.5700
  156. Capallen Confederation 28 Volcanic Bithnia CAP -19.0400 -179.9500
  157. Capallen Confederation 29 Arid Boardwalk CAP -13.8200 -199.2500
  158. Capallen Confederation 30 Arid Bora CAP 39.1200 -159.0900
Add Comment
Please, Sign In to add comment