Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2005-07-12, 10:07 PM
Junior Member
 
Join Date: Jul 2005
Posts: 2
NoobPHP
Default

I can get the first two drop down list(within a form) to work, now the thing is i can't get it to display the results in table after the selections of the drop down lists.. that is to say after the user select the value from the drop down lists.. it should display results onto the table.. How should i do it anyone know?

Code:
// get the aircraft type
$queryAircraftType = "SELECT distinct AircraftType FROM report";
$resultAircraftType = mysql_query($queryAircraftType) or die ("couldn't execute query.");
$row_num_links_mainAircraftType =mysql_num_rows ($resultAircraftType);
Initial Drop down list
Code:
<select name="AircraftType" id="AircraftType" onchange="form.submit();">
<?php while($rowAircraftType = mysql_fetch_array($resultAircraftType)) { 
if($rowAircraftType['AircraftType']==$_GET['AircraftType'])
{ 
echo "<option selected value='$rowAircraftType[AircraftType]'>$rowAircraftType[AircraftType]</option>"."<BR>";} 
else
{ echo "<option value='$rowAircraftType[AircraftType]'>$rowAircraftType[AircraftType]</option>";} 
} 
?> テつ*	
 テつ* テつ* テつ* テつ* テつ* テつ* テつ*</select>
second drop down list populated from initial drop down
Code:
<?php
if (isset($_GET['AircraftType']))
{
$queriesAircraftType = "SELECT AircraftTailNo FROM report where aircrafttype='".$_GET['AircraftType']."'";
//echo $query;
$resultsAircraftType = mysql_query($queriesAircraftType) or die ("couldn't execute query ".mysql_error());
if ($resultsAircraftType)
{
echo "<select name=\"AircraftTailNo\">";
while ($rowsAircraftType = mysql_fetch_array($resultsAircraftType))
{
extract($rowsAircraftType);
echo "<option value=\"".$rowsAircraftType['AircraftTailNo']."\">".$rowsAircraftType['AircraftTailNo']."</option>";
}
echo "</select>";
}
}
?>
Display results within table
Code:
<?php テつ* テつ*
$queryAircraftTypeDisplay = "SELECT * from report where aircraftTailNo='".$_GET['AircraftTailNo']."'";
echo $queryAircraftTypeDisplay;
$resultAircraftTypeDisplay = mysql_query($queryAircraftTypeDisplay) or die ("couldn't execute query ".mysql_error());
while ($row = mysql_fetch_array($resultAircraftTypeDisplay))
{
extract($row);
echo "<tr>
<td>$_GET[AircraftTailNo]</td> 
<td>$row[ReportID]</td>
<td>$row[AircraftTailNo]</td>
<td>$row[AircraftType]</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>";
} テつ*	
?>
Reply With Quote
  #2 (permalink)  
Old 2005-07-13, 08:33 PM
Xnuiem's Avatar
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
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:50 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.