prepare(" SELECT * FROM images -6ren">
gpt4 book ai didi

php - 如何在多个图像的循环上使用网格

转载 作者:行者123 更新时间:2023-11-29 15:22:47 25 4
gpt4 key购买 nike

在下面的代码中,id = "images" 是一个网格,应该从数据库中选择多个图像。但它现在只选择一个。

$stmt = $pdo->prepare("
SELECT *
FROM images i
JOIN journal j
ON j.journalId = i.journalId
JOIN user u
ON u.userId = j.userId
");
$stmt->execute();?>


<body>
<main>
<div id =full>

<?php while($row = $stmt-> fetch()) { ?>
<div id = "userOne">

<div id = "userInfo">
<a href="profile.php"><img src="<?php echo($row["profilepicture"]);?>" alt="profile picture" width="30"/></a>
<div id ="grid">
<h2 id = "one"><?php echo($row["name"]);?>"</h2>
<h3 id = "two"> 2 mins ago </h3>
<h3 id = "three"> Following</h3>
</div>
</div>

<div id = "images">
<div>
<img class = "grid" src="<?php echo($row["moreimages"]);?>" alt="profile picture" width="200"/>
</div>
</div>

<a href="journal.php"><h1><?php echo($row["title"]);?></h1></a>
<h3><?php echo($row["experience"]);?></h3>
</div>
<?php } ?>

</div>
</main>

<footer>
<?php include("includes/footer.php"); ?>
</footer>

</body>

最佳答案

我认为您在查询中使用左联接而不是内联接希望它能起作用

关于php - 如何在多个图像的循环上使用网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59278016/

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