gpt4 book ai didi

php - 回显列中的所有行

转载 作者:太空宇宙 更新时间:2023-11-03 12:30:45 24 4
gpt4 key购买 nike

我需要回显 SQL 列中的所有行。

这是我的PHP

$query2="SELECT * FROM field_activity WHERE field_id='$fetch'";
$result2 = mysql_query($query2);
while($row = mysql_fetch_array($result2)){
$activity = $row['activity'];
$cr_date = date_create($row['date']);
$for_date = date_format($cr_date, 'F j, Y');
$amount = $row['amount'];
$acres_complete = $row['acres_complete'];
$duration = $row['duration'];
$status = $row['status'];
}

这是我的 HTML 输出..

<?php
{
echo "<tr>";
echo "<td width='16%'><strong>Date</strong></td>";
echo "<td width='16%'>$for_date</td>";
echo "</tr><tr>";
echo "<td width='16%'><strong>Activity</strong></td>";
echo "<td width='16%'>$activity</td>";
echo "</tr><tr>";
echo "<td width='16%'><strong>Amount</strong></td>";
echo "<td width='16%'>$amount</td>";
echo "</tr><tr>";
echo "<td width='16%'><strong>Acres Complete</strong></td>";
echo "<td width='16%'>$acres_complete</td>";
echo "</tr><tr>";
echo "<td width='16%'><strong>Duration</strong></td>";
echo "<td width='16%'>$duration</td>";
echo "</tr><tr>";
echo "<td width='16%'><strong>Status</strong></td>";
echo "<td width='16%'>$status</td>";
echo "</tr>";
}
?>

这只显示列中的一行(最新行)。我希望它显示所有行。

最佳答案

您需要在循环中实际执行回显。如果您移动所有 echo while 结尾的语句循环,它将完全按照您的预期工作。您还需要 <table></table> .

关于php - 回显列中的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15514042/

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