View Single Post
  #2 (permalink)  
Old 2005-07-13, 08:33 PM
Xnuiem's Avatar
Xnuiem Xnuiem is offline
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

First, you need to store all the aircraft types soemwhere useful, not in your data table. So either create an array for them, or better yet, store them in thier own table.

aircraftTypeId INT (10) NOT_NULL AUTO_INCREMENT PK
aircraftTypeName VARCHAR (50) NOT_NULL UNIQUE

Then another table to store tail numbers of similar make up.

I honestly wish i could share what I have on this, I am the web development manager for a large aviation company and we have this already built and containging close to about 55K airframes and over 400 types.


Code:
$queryAircraftType = "select * from aircraftType order by aircraftTypeName";
$resultAircraftType = mysql_query($queryAircraftType) or die ("couldn't execute query.");
print("<select name=\"AircraftType\" id=\"AircraftType\" onchange=\"form.submit();\">");

while($rowAircraftType = mysql_fetch_array($resultAircraftType)) {
  if($rowAircraftType['aircraftTypeId']==$_GET['AircraftType']){ $s = "selected"; }
  else { $s = ''; }
  print("<option $s value='$rowAircraftType[aircraftTypeId]'>$rowAircraftType[AircraftTypeName]</option>;"}
  //Using <BR> inside of a select is not valid HTML
}
?>
print("</select>");

second drop down list populated from initial drop down
//USE a good dropdown selector like: http://www.mattkruse.com/javascript/dynamicoptionlist/


Display results within table
CODE

Code:
<?php
$queryAircraftTypeDisplay = "SELECT *.r, a.aircraftTypeName from report r left join aircraftTypeId a on (r.aircraftTypeId = a.aircraftTypeId) where aircraftTailNo='".$_GET['AircraftTailNo']."'";
$resultAircraftTypeDisplay = mysql_query($queryAircraftTypeDisplay) or die ("couldn't execute query ".mysql_error());
while ($row = mysql_fetch_array($resultAircraftTypeDisplay))
{

echo "<tr>
<td>$_GET[AircraftTailNo]</td>
<td>$row[ReportID]</td>
<td>$row[AircraftTailNo]</td>
<td>$row[AircraftTypeName]</td>
<td>$row[ServicingType]</td>
<td>$row[AirFrameHours]</td>
<td>$row[DefectInfo]</td>
<td>$row[Rectifications]</td>
<td>$row[Comments]</td>
<td>$row[RelatedDoc]</td>
<td>$row[UserID]</td>
</tr>";
}
?>
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote