gpt4 book ai didi

Php 将结果提取到表中

转载 作者:行者123 更新时间:2023-12-05 05:47:45 25 4
gpt4 key购买 nike

下面是我的代码,但是,我没有得到我期望的表格。而不是第一行似乎没问题,其他行没有出现在表格中。请引用照片。

    $Sql = "SELECT Registration_Number,Name FROM vta";

$Result = $conn->Query($Sql);


if ($Result -> num_rows> 0) {
echo "<table border=2>
<tr><th>Registration_Number</th>
<th>Name</th></tr>";

while ($Row = $Result->fetch_assoc()) {
// $Rm=$Row['Registration_Number'];
// $Nm = $Row['Name'];

echo "<tr><td>$Row[Registration_Number]</td><td>$Row[Name]</td></tr></table>";
}
}

$conn->Close();

enter image description here

最佳答案

你必须移动关闭</table>在循环之外。

$Sql = "SELECT Registration_Number,Name FROM vta";

$Result = $conn->Query($Sql);


if($Result->num_rows > 0) {
echo "<table border=2>
<tr><th>Registration_Number</th>
<th>Name</th></tr>";

while ($Row = $Result->fetch_assoc()){
echo "<tr><td>$Row['Registration_Number']</td><td>$Row['Name']</td></tr>";
}

echo '</table>';
}

$conn->Close();

关于Php 将结果提取到表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70914860/

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