我有一个机场数据库,我有一个网页,它在一个表格中显示我所有的结果,
我创建了一个下拉框,这样我就可以通过no航班来细化结果,我可以得到航班号来填充,但是当我提交的时候,它似乎不适用于页面,我遵循了我的演讲中的例子,但仍然无法让它发挥作用。随附的任何建议都是我的代码和当前情况的屏幕截图。机场DB
<?php
if ( isset( $_POST[ 'flight' ] ) )
{
$flightNO = $_POST[ 'flight' ];
} else
{
$flightNO = null;
}
$connect = mysqli_connect( "localhost", "root", "" );
mysqli_select_db( $connect, "airportdb" );
?>
<!-- Form -->
<section id="two" class="wrapper style3">
<div class="container">
<h2 align="center">Welcome to Dublin Airport Flight Information Helpdesk</h2>
<div class="container 50%" align="center">
<!-- Dropdown Box -->
<!-- Query -->
<?php
$result = mysqli_query( $connect, "select flight from arrivals" );
?>
<form action="arrivals.php" method="post">
<div class="row uniform" align="center">
<div class="6u 12u$(small)">
<div class="select-wrapper">
<select name="flight">
<option value="All">- All -</option>
<?php
while ( $row = mysqli_fetch_array( $result ) ) {
echo '<option value ="' . $row[ 'flight' ] . ">" . $row[ 'flight' ] . '</option>';
}
echo '</select>';
?>
</div>
</div>
<div class="6u 12u$(small)">
<ul class="actions">
<li><input value="Find" class="special" type="submit">
</li>
</ul>
</div>
</div>
</form>
</div>
</div>
</section>
<!-- Table -->
<section id="three" class=" wrapper style2">
<div class="container">
<div class="table-wrapper">
<?php
if(isset($_POST['flight']))
$result = mysqli_query($connect, "select * from arrivals where flight='$flightNO'");
else
$result = mysqli_query($connect, "select * from arrivals");
echo '<h4>Flight Information for '.date('l d F Y'). ', '. date('h:i:s a'). '</h4>';
echo '<hr>';
echo'<table>';
echo '<thread>
<tr>
<th><font size="+1">Terminal</th>
<th><font size="+1">Origin</th>
<th><font size="+1">Airline</th>
<th><font size="+1">Flight No</th>
<th><font size="+1">Scheduled Date</th>
<th><font size="+1">Scheduled Time</th>
<th><font size="+1">Status</th>
</tr>
</thead>';
while($row=mysqli_fetch_array($result))
{
echo '<tbody align="left">';
echo '<tr>';
echo '<td>' . $row['terminal'] . '</td>';
echo '<td>' . $row['origin'] . '</td>';
echo '<td>' . $row['airline'] . '</td>';
echo '<td>' . $row['flight'] . '</td>';
echo '<td>' . $row['scheduledDate'] . '</td>';
echo '<td>' . $row['scheduledTime'] . '</td>';
echo '<td>' . $row['status'] . '</td>';
echo '</tr>';
echo '</tbody>';
}
echo '</table>';
mysqli_close($connect);
?>
</div>
</div>
</section>
<!--end table php -->发布于 2016-12-02 14:45:37
Saerdn与评论关系密切,但整行与您的不同引号类型有一点不同:
你有:
echo '<option value ="' . $row[ 'flight' ] . ">" . $row[ 'flight' ] . '</option>';你应该做的是:
echo '<option value ="' . $row[ 'flight' ] . '">' . $row[ 'flight' ] . '</option>';发布于 2016-12-02 14:39:33
你可以试试:
if(!empty($flightNO))而不是
if(isset($_POST['flight']))同时,为了调试,请尝试
var_dump($flightNO); 在第一个if/ end语句的末尾,看看里面是什么。
https://stackoverflow.com/questions/40934526
复制相似问题