gpt4 book ai didi

php - 我如何在 while 循环中回显来自 mysql 的两条不同记录

转载 作者:行者123 更新时间:2023-11-30 22:08:30 25 4
gpt4 key购买 nike

我试图在 while loop 中回显两个不同的列输出将在 <td>

这是我的代码:

while($row = mysql_fetch_array($stmt)){
$doc_number = $row['doc_number'];
$place_of_issue = $row['place_of_issue'];
$crew_rank_code = $row['crew_rank_code'];
$full_name = $row['full_name'];
$date_of_birth = $row['date_of_birth'];
$place_of_birth = $row['place_of_birth'];
$date_issue = $row['date_issue'];
$date_expiry = $row['date_expiry'];
$place_of_birth = $row['place_of_birth'];
echo '<tr>';
echo "<td>$crew_rank_code</td>";
echo "<td>$full_name</td>";
echo "<td>$date_of_birth</td>";
echo "<td>$place_of_birth</td>";
echo "<td>". (($row['doc_type'] == '1') ? "$doc_number" : "") . "</td>";
echo "<td>". (($row['doc_type'] == '1') ? "$date_issue" : "") . "</td>";
echo "<td>". (($row['doc_type'] == '1') ? "$date_expiry" : "") . "</td>";
echo "<td>". (($row['doc_type'] == '1') ? "$place_of_issue" : "") . "</td>";
echo "<td>". (($row['doc_type'] == '2') ? "$doc_number" : "") . "</td>";
echo "<td>". (($row['doc_type'] == '2') ? "$date_issue" : "") . "</td>";
echo "<td>". (($row['doc_type'] == '2') ? "$date_expiry" : "") . "</td>";
echo "<td>". (($row['doc_type'] == '2') ? "$place_of_issue" : "") . "</td>";
echo '</tr>';
}

现在,代码给我的输出高达 PASSPORT PLACE ISSUE列,但在那之后,我的代码 echo "<td>". (($row['doc_type'] == '2') ? "$doc_number" : "") . "</td>";不再工作了

我怎样才能制作echo "<td>". (($row['doc_type'] == '2') ? "$doc_number" : "") . "</td>";工作?

先谢谢大家

编辑:

我添加了 mysql

$stmt = mysql_query("select * from info join crew_documents_table on info.id = crew_documents_table.document_crew_id join crew_rank on info.crew_rank = crew_rank.crew_rank_id where crew_rank in ('1','2','3') and crew_status = '$crew_status' and vessel = '$vessel_name' and date_issue in (select max( date_issue ) from crew_documents_table where crew_documents_table.document_crew_id = info.id)")or die(mysql_error());

最佳答案

编辑:对不起,我上次的回答是错误的,你也许应该重写你的 sql 以结束这样的事情

echo "<td>". $row['doc_type'][1]['$doc_number'] . "</td>";

关于php - 我如何在 while 循环中回显来自 mysql 的两条不同记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40905102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com