【发布时间】:2020-06-04 07:32:14
【问题描述】:
我想创建一个循环,以便每次查询“id”时,都会将数据放入单独的块中。想象一下它就像 ebay 上的列表。我知道 foreach 不会这样做,但我不知道如何执行 while 循环。
<?php
include 'sqlconnection.php';
$conn = OpenCon();
$stmt = $conn->prepare("SELECT id from tasks where status='o'");
$stmt->execute();
$res = $stmt->get_result();
$data = $res->fetch_all(MYSQLI_ASSOC);
foreach ($data as $row)
{
echo "<p>" . $row['id'] . "</p>";
}
CloseCon($conn);
?>
这是我要重复的 HTML 块:
<div class="listing-header">
<div class="listing-title">
<p> </p>
</div>
</div>
【问题讨论】:
标签: php html mysql while-loop