【发布时间】:2012-05-02 04:46:06
【问题描述】:
我目前正在调整网站的管理员端,允许网站管理员输入航班号,数据库将提取航班上所有人员的姓名。但是,目前我的结果看起来有点像这样:
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 中的值在从表单发布后被正确分配。
非常感谢,
汤姆
编辑:关于格式的很好的建议,但它仍然是这样打印的:-
以下人员在此航班上
- 加雷斯·罗伯茨
- 乔博客
- 加雷斯·罗伯茨
- 乔博客
- 加雷斯·罗伯茨
- 乔博客
而不是打印,
此航班上有以下人员:-
- 加雷斯·罗伯茨
- 乔博客
只有一次等 :)
【问题讨论】:
-
好的,关于您查询中最近的编辑,我已经编辑了我的回复。 Check here
标签: php mysql html phpmyadmin echo