过去两天我一直在寻找相关的答案,但无法做出任何答案。
我正在使用 javascript、PHP 和 SQL 创建一个网页,最终将比我所要求的更强大,但目前这是我的问题。
我有一个初始下拉列表,其中填充了 SQL 数据库中 39 个不同表(星座或卫星组)的名称。基于第一个 SQL 查询,在提交时,页面将整个表格显示为页面底部的 html。
此外,第二个查询填充第二个下拉列表(星座内的特定卫星/对象),该列表显示所选表中每行的名称。第二个下拉列表显示正常。
但是,当我在第二个下拉菜单后单击提交时,查询应该被传递到一个 html 表,以仅显示第二个查询中选择的行信息(卫星/对象的轨道参数)。相反,当我单击提交时,表格中没有显示任何内容,并且页面刷新以返回其初始状态。我不知道如何成功地将查询传递给表。每个表包含 8 到 2700 个不同的对象(总共超过 6000 个),所以我不能简单地列出每一行,特别是因为数据每天都在变化。
表格中的数据最终将用于使用 java 或其他方法计算轨道,并将它们显示在嵌入式谷歌地球页面中。
我熟悉 javascript、php 和 sql,但不太熟悉其他方法,但我愿意接受建议。
以下是页面的相关代码。
<?php
if (isset($_POST['constellation'])) {
$constellation = $_POST['constellation']; }
else {
$constellation = 'Space Stations';
}
if (isset($_POST['satellite'])) {
$satellite = $_POST['satellite']; }
else {
$satellite = 'ISS (Zarya)';
}
?>
<p>Use the pull-down menu's to choose the specific constellation (group) of satellites to view the most recent orbital data.</a></p>
<hr />
<div class="masterpulldown">
<table class="pulldown">
<tr>
<td "colspan="2">
<p class="pulldownheader">Constellation Query</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="pulldownGroup" name="pulldownGroup" method="post" >
<select id="constellation" name="constellation" value=$constellation >
<option value="Last 30 Days" <?php if($constellation=="Last 30 Days") echo "selected"; ?> >Last 30 Days</option>
<option value="Space Stations" <?php if($constellation=="Space Stations") echo "selected"; ?> >Space Stations</option>
<option value="100 (Or So) Brightest" <?php if($constellation=="100 (Or So) Brightest") echo "selected"; ?> >100 (Or So) Brightest</option>
<option value="Weather" <?php if($constellation=="Weather") echo "selected"; ?> >Weather</option>
<option value="Noaa" <?php if($constellation=="Noaa") echo "selected"; ?> >Noaa</option>
<option value="Goes" <?php if($constellation=="Goes") echo "selected"; ?> >Goes</option>
<option value="Earth Resources" <?php if($constellation=="Earth Resources") echo "selected"; ?> >Earth Resources</option>
<option value="Search And Rescue (Sarsat)" <?php if($constellation=="Search And Rescue (Sarsat)") echo "selected"; ?> >Search And Rescue (Sarsat)</option>
<option value="Disaster Monitoring" <?php if($constellation=="Disaster Monitoring") echo "selected"; ?> >Disaster Monitoring</option>
<option value="Tracking And Data Relay Satellite System (Tdrss)" <?php if($constellation=="Tracking And Data Relay Satellite System (Tdrss)") echo "selected"; ?> >Tracking And Data Relay Satellite System (Tdrss)</option>
<option value="Geostationary" <?php if($constellation=="Geostationary") echo "selected"; ?> >Geostationary</option>
<option value="Intelsat" <?php if($constellation=="Intelsat") echo "selected"; ?> >Intelsat</option>
<option value="Gorizont" <?php if($constellation=="Gorizont") echo "selected"; ?> >Gorizont</option>
<option value="Raduga" <?php if($constellation=="Raduga") echo "selected"; ?> >Raduga</option>
<option value="Molniya" <?php if($constellation=="Molniya") echo "selected"; ?> >Molniya</option>
<option value="Iridium" <?php if($constellation=="Iridium") echo "selected"; ?> >Iridium</option>
<option value="Orbcomm" <?php if($constellation=="Orbcomm") echo "selected"; ?> >Orbcomm</option>
<option value="Globalstar" <?php if($constellation=="Globalstar") echo "selected"; ?> >Globalstar</option>
<option value="Amateur Radio" <?php if($constellation=="Amateur Radio") echo "selected"; ?> >Amateur Radio</option>
<option value="Experimental" <?php if($constellation=="Experimental") echo "selected"; ?> >Experimental</option>
<option value="Communication Satellites - Other" <?php if($constellation=="Communication Satellites - Other") echo "selected"; ?> >Communication Satellites - Other</option>
<option value="Gps Operational" <?php if($constellation=="Gps Operational") echo "selected"; ?> >Gps Operational</option>
<option value="Glonass Operational" <?php if($constellation=="Glonass Operational") echo "selected"; ?> >Glonass Operational</option>
<option value="Galileo" <?php if($constellation=="Galileo") echo "selected"; ?> >Galileo</option>
<option value="Satellite-Based Augmentation System" <?php if($constellation=="Satellite-Based Augmentation System") echo "selected"; ?> >Satellite-Based Augmentation System</option>
<option value="Navy Navigation Satellite System (Nnss)" <?php if($constellation=="Navy Navigation Satellite System (Nnss)") echo "selected"; ?> >Navy Navigation Satellite System (Nnss)</option>
<option value="Russian Leo Navigation" <?php if($constellation=="Russian Leo Navigation") echo "selected"; ?> >Russian Leo Navigation</option>
<option value="Space And Earth Science" <?php if($constellation=="Space And Earth Science") echo "selected"; ?> >Space And Earth Science</option>
<option value="Geodetic" <?php if($constellation=="Geodetic") echo "selected"; ?> >Geodetic</option>
<option value="Engineering" <?php if($constellation=="Engineering") echo "selected"; ?> >Engineering</option>
<option value="Education" <?php if($constellation=="Education") echo "selected"; ?> >Education</option>
<option value="Miscellaneous Military" <?php if($constellation=="Miscellaneous Military") echo "selected"; ?> >Miscellaneous Military</option>
<option value="Radar Calibration" <?php if($constellation=="Radar Calibration") echo "selected"; ?> >Radar Calibration</option>
<option value="Cubesats" <?php if($constellation=="Cubesats") echo "selected"; ?> >Cubesats</option>
<option value="Miscellaneous Satellites - Other" <?php if($constellation=="Miscellaneous Satellites - Other") echo "selected"; ?> >Miscellaneous Satellites - Other</option>
<option value="Fengyun 1C Debris" <?php if($constellation=="Fengyun 1C Debris") echo "selected"; ?> >Fengyun 1C Debris</option>
<option value="Iridium 33 Debris" <?php if($constellation=="Iridium 33 Debris") echo "selected"; ?> >Iridium 33 Debris</option>
<option value="Cosmos 2251 Debris" <?php if($constellation=="Cosmos 2251 Debris") echo "selected"; ?> >Cosmos 2251 Debris</option>
<option value="Breeze-M Breakup" <?php if($constellation=="Breeze-M Breakup") echo "selected"; ?> >Breeze-M Breakup</option>
<input id="submit" type=submit value=submit />
</form>
</select>
</td>
</tr>
</table>
<?php
require_once('connectvars.php');
// require_once('appvars.php');
// Connect to the database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$a1=array("Last30Days","SpaceStations","HundredOrSoBrightest","Weather","Noaa","Goes","EarthResources","SearchAndRescueSarsat","DisasterMonitoring","TrackingAndDataRelaySatelliteSystemTdrss","Geostationary","Intelsat","Gorizont","Raduga","Molniya","Iridium","Orbcomm","Globalstar","AmateurRadio","Experimental","CommunicationSatellitesOther","GpsOperational","GlonassOperational","Galileo","SatelliteBasedAugmentationSystem","NavyNavigationSatelliteSystemNnss","RussianLeoNavigation","SpaceAndEarthScience","Geodetic","Engineering","Education","MiscellaneousMilitary","RadarCalibration","Cubesats","MiscellaneousSatellitesOther","Fengyun1CDebris","Iridium33Debris","Cosmos2251Debris","BreezeMRBBreakup");
$a2=array("Last 30 Days","Space Stations","100 (Or So) Brightest","Weather","Noaa","Goes","Earth Resources","Search And Rescue (Sarsat)","Disaster Monitoring","Tracking And Data Relay Satellite System (Tdrss)","Geostationary","Intelsat","Gorizont","Raduga","Molniya","Iridium","Orbcomm","Globalstar","Amateur Radio","Experimental","Communication Satellites - Other","Gps Operational","Glonass Operational","Galileo","Satellite-Based Augmentation System","Navy Navigation Satellite System (Nnss)","Russian Leo Navigation","Space And Earth Science","Geodetic","Engineering","Education","Miscellaneous Military","Radar Calibration","Cubesats","Miscellaneous Satellites - Other","Fengyun 1C Debris","Iridium 33 Debris","Cosmos 2251 Debris","Breeze-M Breakup");
$arr=array_combine($a1, $a2);
$Last30Days = $arr["Last30Days"];
$SpaceStations = $arr["SpaceStations"];
$HundredOrSoBrightest = $arr["HundredOrSoBrightest"];
$Weather = $arr["Weather"];
$Noaa = $arr["Noaa"];
$Goes = $arr["Goes"];
$EarthResources = $arr["EarthResources"];
$SearchAndRescueSarsat = $arr["SearchAndRescueSarsat"];
$DisasterMonitoring = $arr["DisasterMonitoring"];
$TrackingAndDataRelaySatelliteSystemTdrss = $arr["TrackingAndDataRelaySatelliteSystemTdrss"];
$Geostationary = $arr["Geostationary"];
$Intelsat = $arr["Intelsat"];
$Gorizont = $arr["Gorizont"];
$Raduga = $arr["Raduga"];
$Molniya = $arr["Molniya"];
$Iridium = $arr["Iridium"];
$Orbcomm = $arr["Orbcomm"];
$Globalstar = $arr["Globalstar"];
$AmateurRadio = $arr["AmateurRadio"];
$Experimental = $arr["Experimental"];
$CommunicationSatellitesOther = $arr["CommunicationSatellitesOther"];
$GpsOperational = $arr["GpsOperational"];
$GlonassOperational = $arr["GlonassOperational"];
$Galileo = $arr["Galileo"];
$SatelliteBasedAugmentationSystem = $arr["SatelliteBasedAugmentationSystem"];
$NavyNavigationSatelliteSystemNnss = $arr["NavyNavigationSatelliteSystemNnss"];
$RussianLeoNavigation = $arr["RussianLeoNavigation"];
$SpaceAndEarthScience = $arr["SpaceAndEarthScience"];
$Geodetic = $arr["Geodetic"];
$Engineering = $arr["Engineering"];
$Education = $arr["Education"];
$MiscellaneousMilitary = $arr["MiscellaneousMilitary"];
$RadarCalibration = $arr["RadarCalibration"];
$Cubesats = $arr["Cubesats"];
$MiscellaneousSatellitesOther = $arr["MiscellaneousSatellitesOther"];
$Fengyun1CDebris = $arr["Fengyun1CDebris"];
$Iridium33Debris = $arr["Iridium33Debris"];
$Cosmos2251Debris = $arr["Cosmos2251Debris"];
$BreezeMRBBreakup = $arr["BreezeMRBBreakup"];
$a3=array($Last30Days,$SpaceStations,$HundredOrSoBrightest,$Weather,$Noaa,$Goes,$EarthResources,$SearchAndRescueSarsat,$DisasterMonitoring,$TrackingAndDataRelaySatelliteSystemTdrss,$Geostationary,$Intelsat,$Gorizont,$Raduga,$Molniya,$Iridium,$Orbcomm,$Globalstar,$AmateurRadio,$Experimental,$CommunicationSatellitesOther,$GpsOperational,$GlonassOperational,$Galileo,$SatelliteBasedAugmentationSystem,$NavyNavigationSatelliteSystemNnss,$RussianLeoNavigation,$SpaceAndEarthScience,$Geodetic,$Engineering,$Education,$MiscellaneousMilitary,$RadarCalibration,$Cubesats,$MiscellaneousSatellitesOther,$Fengyun1CDebris,$Iridium33Debris,$Cosmos2251Debris,$BreezeMRBBreakup);
$a4=array("Last30Days","SpaceStations","HundredOrSoBrightest","Weather","Noaa","Goes","EarthResources","SearchAndRescueSarsat","DisasterMonitoring","TrackingAndDataRelaySatelliteSystemTdrss","Geostationary","Intelsat","Gorizont","Raduga","Molniya","Iridium","Orbcomm","Globalstar","AmateurRadio","Experimental","CommunicationSatellitesOther","GpsOperational","GlonassOperational","Galileo","SatelliteBasedAugmentationSystem","NavyNavigationSatelliteSystemNnss","RussianLeoNavigation","SpaceAndEarthScience","Geodetic","Engineering","Education","MiscellaneousMilitary","RadarCalibration","Cubesats","MiscellaneousSatellitesOther","Fengyun1CDebris","Iridium33Debris","Cosmos2251Debris","BreezeMRBBreakup");
$arr=array_combine($a3, $a4);
$query = "SELECT * FROM $arr[$constellation] order by mission ASC";
$data = mysqli_query($dbc, $query);
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="pulldownGroup2" name="pulldownGroup" method="post" >
<table class="pulldown">
<tr>
<td colspan="2">
<p class="pulldownheader">Satellite Results (Norad Number and Satellite Name)</p>
<select id="satellite" name="satellite" value=$satellite >
<option class="subdued" value=$satellite>Select for Satellite or leave blank for Constellation</option>
<?php
$i = 0;
while ($row = mysqli_fetch_array($data)) {
// Display the satellite data
if ($i == 0) {
echo '<option value=$satellite>' . $row['mission'] . ' ' . $row['satellite'] . '</option>';
}
}
?>
<input id="submit" type=submit value=submit />
</select>
</td>
</tr>
</table>
<?php
//while ($row = mysqli_fetch_array($data)) {
?>
<table class="chosensat">
<tr>
<td class="sat2">Satellite Mission and Name: <?php $row['mission'] . ' ' . $row['satellite']; ?></td>
</tr>
<tr>
<td class="sat2">Epoch Time and Greenwich time: <?php $row['epochTime'] . ' ' . $row['gmtTime']; ?></td>
</tr>
<tr>
<td class="sat2">Inclination: <?php $row['inclination']; ?> deg</td>
</tr>
<tr>
<td class="sat2">Right Ascension: <?php $row['raan']; ?> deg</td>
</tr>
<tr>
<td class="sat2">Eccentricity: <?php $row['eccentricity']; ?></td>
</tr>
<tr>
<td class="sat2">Argument of Perigee: <?php $row['argOfPerigee']; ?> deg</td>
</tr>
<tr>
<td class="sat2">Mean Anomaly: <?php $row['meanAnomaly']; ?> deg</td>
</tr>
<tr>
<td class="sat2">Mean Motion: <?php $row['meanMotion']; ?> rev/day</td>
</tr>
</table>
<?php
//}
?>
</form>
<p class="pulldownheader2">Selected Constellation:
<?php
if($constellation=="Last 30 Days") echo $Last30Days;
elseif($constellation=="Space Stations") echo $SpaceStations;
elseif($constellation=="Hundred Or So Brightest") echo $HundredOrSoBrightest;
elseif($constellation=="Weather") echo $Weather;
elseif($constellation=="Noaa") echo $Noaa;
elseif($constellation=="Goes") echo $Goes;
elseif($constellation=="Earth Resources") echo $EarthResources;
elseif($constellation=="Search And Rescue (Sarsat)") echo $SearchAndRescueSarsat;
elseif($constellation=="Disaster Monitoring") echo $DisasterMonitoring;
elseif($constellation=="Tracking And Data Relay Satellite System (Tdrss)") echo $TrackingAndDataRelaySatelliteSystemTdrss;
elseif($constellation=="Geostationary") echo $Geostationary;
elseif($constellation=="Intelsat") echo $Intelsat;
elseif($constellation=="Gorizont") echo $Gorizont;
elseif($constellation=="Raduga") echo $Raduga;
elseif($constellation=="Molniya") echo $Molniya;
elseif($constellation=="Iridium") echo $Iridium;
elseif($constellation=="Orbcomm") echo $Orbcomm;
elseif($constellation=="Globalstar") echo $Globalstar;
elseif($constellation=="Amateur Radio") echo $AmateurRadio;
elseif($constellation=="Experimental") echo $Experimental;
elseif($constellation=="Communication Satellites - Other") echo $CommunicationSatellitesOther;
elseif($constellation=="Gps Operational") echo $GpsOperational;
elseif($constellation=="Glonass Operational") echo $GlonassOperational;
elseif($constellation=="Galileo") echo $Galileo;
elseif($constellation=="Satellite-Based Augmentation System") echo $SatelliteBasedAugmentationSystem;
elseif($constellation=="Navy Navigation Satellite System (Nnss)") echo $NavyNavigationSatelliteSystemNnss;
elseif($constellation=="Russian Leo Navigation") echo $RussianLeoNavigation;
elseif($constellation=="Space And Earth Science") echo $SpaceAndEarthScience;
elseif($constellation=="Geodetic") echo $Geodetic;
elseif($constellation=="Engineering") echo $Engineering;
elseif($constellation=="Education") echo $Education;
elseif($constellation=="Miscellaneous Military") echo $MiscellaneousMilitary;
elseif($constellation=="Radar Calibration") echo $RadarCalibration;
elseif($constellation=="Cubesats") echo $Cubesats;
elseif($constellation=="Miscellaneous Satellites - Other") echo $MiscellaneousSatellitesOther;
elseif($constellation=="Fengyun 1C Debris") echo $Fengyun1CDebris;
elseif($constellation=="Iridium 33 Debris") echo $Iridium33Debris;
elseif($constellation=="Cosmos 2251 Debris") echo $Cosmos2251Debris;
elseif($constellation=="Breeze Breakup") echo $BreezeMRBBreakup;
else echo $constellation;
?>
</p>
</div>
<div id="map3d"></div>
<?php
// Retrieve the data from MySQL
$query2 = "SELECT * FROM $arr[$constellation] ORDER BY id ASC";
$data2 = mysqli_query($dbc, $query2);
// Loop through the array of data, formatting it as HTML
echo '<table class="tablecontent">';
echo '<tr><td colspan="11" class="constellationheader">' . $constellation . '</td></tr>';
echo '<tr><th width="20px" class="headerinfo"><strong>ID:</strong></th>';
echo '<th width="180px" class="headerinfo"><strong>Satellite:</strong></th>';
echo '<th class="headerinfo"><strong>Mission:</strong></th>';
echo '<th class="headerinfo"><strong>Epoch Time:</strong></th>';
echo '<th width="160px" class="headerinfo"><strong>GMT:</strong></th>';
echo '<th class="headerinfo"><strong>Inclination:</strong></th>';
echo '<th class="headerinfo"><strong>RAAN:</strong></th>';
echo '<th class="headerinfo"><strong>Eccentricity:</strong></th>';
echo '<th width="120px" class="headerinfo"><strong>Argument of Perigee:</strong></th>';
echo '<th class="headerinfo"><strong>Mean Anomaly:</strong></th>';
echo '<th class="headerinfo"><strong>Mean Motion:</strong></th></tr>';
$i = 0;
while ($row = mysqli_fetch_array($data2)) {
// Display the satellite data
if ($i == 0) {
echo '<tr><td align="center" width="20px" class="sat">' . $row['id'] . '</td>';
echo '<td width="180px" class="sat">' . $row['satellite'] . '</td>';
echo '<td class="sat">' . $row['mission'] . '</td>';
echo '<td class="sat">' . $row['epochTime'] . '</td>';
echo '<td width="160px" class="sat">' . $row['gmtTime'] . '</td>';
echo '<td class="sat">' . $row['inclination'] . ' deg' . '</td>';
echo '<td class="sat">' . $row['raan'] . ' deg' . '</td>';
echo '<td class="sat">' . $row['eccentricity'] . '</td>';
echo '<td width="120px" class="sat">' . $row['argOfPerigee'] . ' deg' . '</td>';
echo '<td class="sat">' . $row['meanAnomaly'] . ' deg' . '</td>';
echo '<td class="sat">' . $row['meanMotion'] . ' rev/day' . '</td></tr>';
}
}
echo '</table>';
mysqli_close($dbc);
?>
任何帮助,将不胜感激。我对这一切都不是很有经验,但我很高兴学习。