我正在使用下面的代码来回显表格中的结果。但是,结果会在每次循环时产生新的行。但是我希望数据库的第一行数据能够在第一列中回显,然后移动到下一行数据的下一列。简单地说,指的是图片浏览: Desired Outcome如何将2行结果回显到2列的表格
我想要什么:
$result = mysqli_query($conn, "SELECT * FROM contact WHERE category='other'");
if ($result->num_rows > 0)
{
while ($row = $result->fetch_object())
{
echo "<tr>";
echo "<td width=500><b>". $row->name . "</b><br/>Address: ". $row->address . "<br/>Phone no: ". $row->phoneno . "<br/>Fax No:". $row->faxno ."<br/>Email: ". $row->email . "<br/>Website: ". $row->website ."</td>";
//echo "</tr>";
//echo "<tr>";
//fetch next object here
echo "<td width=500><b>". $row->name . "</b><br/>Address: ". $row->address . "<br/>Phone no: ". $row->phoneno . "<br/>Fax No:". $row->faxno ."<br/>Email: ". $row->email . "<br/>Website: ". $row->website ."</td>";
echo "</tr>";
}
echo "</table>";
}
试试我的答案,它给你什么预期的结果 – JYoThI