我现在正在调整网站的管理员端,允许网站管理员输入航班号,数据库将提取航班上所有人员的姓名。但是,目前我的结果看起来有点像这样:
The following people are on this flight Joe BloggsThe following people are on this flight Gareth RobertsThe following people are on this flight Joe BloggsThe following people are on this flight Gareth RobertsThe following people are on this flight Joe BloggsThe following people are on this flight Gareth RobertsThe following people are on this flight Joe BloggsThe following people are on this flight Gareth RobertsThe following people are on this flight Joe BloggsThe following people are on this flight Gareth RobertsThe following people are on this flight Joe Bloggs
你明白了……名字显然是出于 DPA 的原因 :)
我怎样才能让它说例如:
2021 号航班上的乘客是:
- 命名一个
- 命名两个
- 命名三
这是我的代码,我欢迎任何建议!
<?
include("logon/include/session.php");
$loggedinuser = $session->username;
$passengerNo = $_POST['enteredPassNo'];
$theflightno = $_POST['enteredflightNo'];
$query1 = mysql_query("SELECT p.surname, p.forename, p.passNo FROM PASSENGER p WHERE p.passNo = '$passengerNo'");
while($row = mysql_fetch_array($query1))
{
echo "Welcome to the site" . " " . $row['forename'] ." ";
}
echo mysql_error();
$query2 = mysql_query("SELECT p.surname, p.forename, p.passNo, p.flightNo FROM PASSENGER p, FLIGHT_INFO f WHERE p.flightNo = '$theflightno'");
while($row = mysql_fetch_array($query2))
{
echo "The following people are on this flight" . "</ br> ";
echo $row['forename'] ." " . $row['surname'];
echo "</ br>";
echo mysql_error();
}
echo mysql_error();
?>
重点是 query2,query1 确实用于一些测试!澄清一下,存储在 $passengerNo 和 $theflightNo 中的值在从表单发布后被正确分配。
非常感谢,
汤姆
编辑:关于格式的很好的建议,但它仍然是这样打印的:-
以下人员在此航班上
- 加雷斯·罗伯茨
- 乔·博格斯
- 加雷斯·罗伯茨
- 乔·博格斯
- 加雷斯·罗伯茨
- 乔·博格斯
而不是打印,
以下人员在此航班上:-
- 加雷斯·罗伯茨
- 乔·博格斯
只有一次等:)