Jump to content

One Line?


Cooper94

Recommended Posts

I have this problem were it is showing all the flights that the user booked but it wont seperate:

http://www.republicv.org/site1/options.php?content=bid

Code:

<?php include 'includes/session.php';
include 'data.php';
?>
<form action="" method="post">
<table width=100% align=center>
<tr align=center><td width=50%>Departure Airport</td><td align=left>
<input name="dep" value="">
<tr align=center><td>Arrival Airport</td><td align=left>
<input name="arr" value="">
<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></td><td align=left><input type="submit" value="Search Timetable"></td></tr>
</form>
<?php $result = mysql_query("SELECT * FROM book WHERE username='{$_SESSION['username']}'");
$num = mysql_num_rows($result);
?>
<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></b></td></tr>
<tr align=center>
<?php
while ($row = mysql_fetch_array($result))
{
echo "<td>{$row['flightnum']}</td>";
echo "<td>{$row['dep_icao']}</td>";
echo "<td>{$row['arr_icao']}</td>";
echo "<td>{$row['aircraft']}</td>";
}
?>
<td><a href=?content=dispatch&id=22443>Flight Info</a><br>
<a href=?content=delete-flight&id=22443>Delete</a></td>
</tr>
</table>
</td></tr>
</table>

Link to comment
https://forums.phpfreaks.com/topic/145403-one-line/
Share on other sites

I'm guessing you should have your <tr> and </tr> inside the while loop

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=?content=dispatch&id=22443>Flight Info</a><br><a href=?content=delete-flight&id=22443>Delete</a></td></tr>";
}

Link to comment
https://forums.phpfreaks.com/topic/145403-one-line/#findComment-763335
Share on other sites

Thank You and one other thing why isnt this working?

<?php include 'includes/session.php';
include 'data.php';
?>

<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>
<input name="dep" value="">
<tr align=center><td>Arrival Airport</td><td align=left>
<input name="arr" value="">
<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></td><td align=left><input type="submit" value="Search Timetable"></td></tr>
</form>
<?php if(isset($_POST['submit'])) { 
exit();
}
?>
<?php $result = mysql_query("SELECT * FROM book WHERE username='{$_SESSION['username']}'");
$num = mysql_num_rows($result);
?>
<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
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=?content=dispatch&id=22443>Flight Info</a><br><a href=?content=delete-flight&id=22443>Delete</a></td></tr>";
}
?>
</table>
</td></tr>
</table>

Link to comment
https://forums.phpfreaks.com/topic/145403-one-line/#findComment-763340
Share on other sites

I'd guess possibly because of this:

if(isset($_POST['submit'])) { 
exit();
}

which terminates the script after redisplaying the form, but without actually doing anything with the values that the user has submitted

 

Are you really trying to use tables for your layout though?

If you must do that rather than using css, then it helps if the table is properly constructed (e.g. closing off a row with a </tr> before opening the next row)

Link to comment
https://forums.phpfreaks.com/topic/145403-one-line/#findComment-763475
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.