Jump to content

Two Things


Cooper94

Recommended Posts

Hi there everyone just a couple questions one is why wont it show all the arr_icao codes in the options. Like I want it to show every arr_icao in that db. Also why isnt the booked flights showing on the bottom. It all seems like the code is correct. Thank you for the help code:

<?php include 'includes/session.php';
include 'data.php';
$sql = "SELECT * FROM pilots WHERE username = '{$_SESSION['username']}'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
?>
<center><a href="options.php?content=bid">My Flights</a></center>
<form method="post" action="http://www.republicv.org/site1/options.php?content=bid">
<table width=100% align=center>
<tr align=center><td width=50%>Departure Airport</td><td align=left>
<select name="dep">
<option value="all">Select All</option>
<option value="KCLT">KCLT</option>
</select>
<tr align=center><td>Arrival Airport</td><td align=left>
<select name="arr">
<option value="all">Select All</option>
<?php
$result = mysql_query("select * from flights'");
$num = mysql_num_rows($result);
while ($row = mysql_fetch_array($result))
{
echo "<option value = '{$row['arr_icao']}'>{$row['arr_icao']}</option>";
}
?>
</select>
<tr align=center><td>Aircraft</td><td align=left>
<select name="aircraft">
<option value="Select Aircraft"></option>
<option value="ERJ-170/175">ERJ-170/175</option>
</select></td></tr>
<tr align=center><td>Select All</td><td align=left>
<input type="checkbox" name="all" value="8.0">
<tr align=center><td></td><td align=left><input type="submit" name="submit" value="Search Timetable"></td></tr>
</form>
<?php
  if (isset($_GET['del'])) {
mysql_query("DELETE FROM book WHERE flightnum='{$_GET['del']}' AND username='{$_SESSION['username']}'");
}
?>
<tr><td colspan=2><hr height=1 width=100%></td></tr>
<tr><td colspan=2 align=center>
<table width=100%>
<tr align=center>
<td><b>Flight Number</b></td>
<td><b>Departure Airport</b></td>
<td><b>Arrival Airport</b></td>
<td><b>Aircraft</b></td>
<td><b>Action</b></td></tr>
<?php if(isset($_POST['submit'])) { 
$dep=$_POST['dep'];
$dep = stripslashes($dep);
$dep = mysql_real_escape_string($dep);
$arr=$_POST['arr'];
$arr = stripslashes($arr);
$arr = mysql_real_escape_string($arr);
$all = mysql_real_escape_string($_POST['all']);

if ($dep == "all" AND $arr == "all") {
$query = "SELECT * FROM flights WHERE dep_icao LIKE '%' AND arr_icao LIKE '%' ";} 
elseif ($dep == "all" AND $arr != "all") {
$query = "SELECT * FROM flights WHERE dep_icao LIKE '%' AND arr_icao='$arr' ";} 
elseif ($dep != "all" AND $arr == "all") {
$query = "SELECT * FROM flights WHERE dep_icao='$dep' AND arr_icao LIKE '%' ";}
elseif ($dep != "all" AND $arr != "all") {
$query = "SELECT * FROM flights WHERE dep_icao='$dep' AND arr_icao='$arr' ";}
else{}

$result = mysql_query($query);
$num = mysql_num_rows($result);
while ($row = mysql_fetch_array($result))
{
   echo "<tr align=center>";
   echo "<td>{$row['flightnum']}</td>";
   echo "<td>{$row['dep_icao']}</td>";
   echo "<td>{$row['arr_icao']}</td>";
   echo "<td>{$row['aircraft']}</td>";

   echo "<td><a href=options.php?content=bookit&id={$row['flightnum']}>Book</a><br><a href=flights.php?flights={$row['flightnum']}>Flight Info</a></td></tr>";
}
}
?>
<?php
$results = mysql_query("SELECT * FROM book WHERE username='{$_SESSION['username']}'");
$nums = mysql_num_rows($results);
if ($nums >= '0'){
}else{
while ($rows = mysql_fetch_array($results))
{
   echo "<tr align=center>";
   echo "<td>{$rows['flightnum']}</td>";
   echo "<td>{$rows['dep_icao']}</td>";
   echo "<td>{$rows['arr_icao']}</td>";
   echo "<td>{$rows['aircraft']}</td>";

   echo "<td><a href=flights.php?flights={$rows['flightnum']}>Flight Info</a><br><a href=http://www.republicv.org/site1/options.php?content=bid&del={$rows['flightnum']}>Delete</a></td></tr>";
}}
?>
</table>
</td></tr>
</table>

Link to comment
https://forums.phpfreaks.com/topic/146035-two-things/
Share on other sites

Archived

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

×
×
  • Create New...

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.