我的商店表如下:
| strid | userid |
__________________
| 9 | 35 |
| 17 | 44 |
我的产品表如下:
| prodid | userid | strid |
___________________________
| 9 | 35 | 9 |
| 10 | 44 | 17 |
| 11 | 44 | 17 |
我想回显如下结果:
-----------------
| STORE ID: 9 |
-----------------
| PRODUCT ID: 9 |
-----------------
------------------
| STORE ID: 17 |
------------------
| PRODUCT ID: 10 |
| PRODUCT ID: 11 |
------------------
基本上,我想回显strid列,并在其下方回显与其对应的prodid's
链接的所有strid
。
我目前拥有的代码仅回显一个商店的信息,而不回显其他商店的信息:
<?php
$sql = "SELECT strid FROM store ORDER BY strid DESC";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$strid1 = $row["strid"];
?>
<div class="spct">STRID: <?php echo $strid1; ?>
<?php
$sql = "SELECT * FROM prodtabs WHERE strid='$strid1'";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$prodid2 = $row["prodid"];
$userid2 = $row["userid"];
$strid2 = $row["strid"];
?>
<div class="spct">PRODID: <?php echo $prodid2; ?></div>
<?php } ?>
</div>
<?php } ?>
请帮助我吗?