【发布时间】:2013-12-08 14:39:33
【问题描述】:
我有一个包含帖子字段的帖子表。假设我想在 10 个 div 中显示 10 个帖子。我应该如何继续这样做?我已经设法使用 while 循环获取全部内容,但它只在一个地方显示全部内容,我希望每个帖子都有单独的 div(这样我可以使用不同的背景颜色)。
请帮帮我,我希望这是有道理的。例如,想想 facebook 显示帖子的方式。每个帖子都有自己的盒子。我想要类似的东西。
我必须获取帖子的代码片段可在此处获得:
<?php
require_once("includes/database.php"); // Get the database connection
$get_post = "SELECT full_post FROM posts";
$show_post = mysqli_query($connection, $get_post);
if (!$show_post) {
echo "Could not load post. " . "(" . mysqli_error($connection) . ")";
}
while ($post = mysqli_fetch_assoc($show_post)) {
echo $post["full_post"] . "<br />";
}
mysqli_free_result($show_post);
?>
【问题讨论】:
-
请显示一些代码
-
向我们展示您的代码,以便我们按照您的意愿进行操作。
-
代码示例或者它没有发生。
-
第一篇文章中添加的代码示例。谢谢