Jump to content

Archived

This topic is now archived and is closed to further replies.

Andrew R

Flight searcher

Recommended Posts

Hello

I need some help on modifying my flight searcher.  For example, I select Departure airport as “Miami”, arrival airport as “Dublin”, Aircraft as “Airbus A300” and day as “Sunday”.  Once I press submit the form will go to viewroutes.php and display the routes that match the query above. The problem I’m having is the scripts below only allow for one query at a time i.e. I can only display routes on a Monday or any other day.  I believe the problem is in the sql query on the viewroutes.php page.  How would I modify it to allow a query like the one above?

Here are the codes I’m using below.

[code]<form action="viewroutes.php" method="post" name="day" id="day">
  <table width="492" border="0" cellpadding="0" cellspacing="0">
    <!--DWLayoutTable-->
    <tr>
      <td width="133" height="25" valign="middle" bgcolor="#CCCCCC">Departing
        From:</td>
      <td width="359" valign="top"><select name="dep" id="dep">
          <option selected>Dublin</option>
          <option>Shannon</option>
          <option>Miami</option>
        </select>
      </td>
    </tr>
    <tr>
      <td height="24" valign="middle" bgcolor="#CCCCCC">Arrival:</td>
      <td valign="top"><select name="arr" id="arr">
          <option selected>Dublin</option>
          <option>Shannon</option>
          <option>Miami</option>
        </select>
        &nbsp; </td>
    </tr>
    <tr>
      <td height="24" valign="top" bgcolor="#CCCCCC">Aircraft:</td>
      <td valign="top"><select name="aircraft" id="aircraft">
          <option selected>Airbus A300</option>
          <option>Airbus A310</option>
        </select>
      </td>
    </tr>
    <tr>
      <td height="24" valign="top" bgcolor="#CCCCCC">Day:</td>
      <td valign="top"><select name="formquery" id="formquery">
          <option selected>Sunday</option>
          <option>Monday</option>
          <option>Tuesday</option>
          <option>Wednesday</option>
          <option>Thursday</option>
          <option>Friday</option>
          <option>Saturday</option>
        </select>
        <input name="formtype" type="hidden" id="formtype" value="day"> &nbsp;</td>
    </tr>
    <tr>
      <td height="24">&nbsp;</td>
      <td valign="top"><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
    </tr>
  </table>
</form>[/code] (search.php)

[code]$query_routes = "SELECT * FROM routes where $formtype like '$formquery'";[/code] (SQL query on viewroutes.php)

Thanks

Share this post


Link to post
Share on other sites
You have to include all filters in the sql query:

$sql = "SELECT * FROM routes where dep = '$dep' && arr='$arr' && aircraft='$aircraft' && formquery like '$formquery'";

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.