我正试图从mysql中获取一些数据,如论坛名称注释号。
我的代码看起来像那样
<?php foreach(fetch('forum_threads', 'limit=5') as $forum_thread) : ?>
<?php foreach(fetch('forums', 'limit=5') as $forum) : ?>
<?php foreach(fetch('forum_sections', 'limit=5') as $forum_section) : ?>
<li>
<img src="/themes/<?php echo setting('themes.default_theme') ?>/assets/images/ico/neo-white.png">
<a href="#comments" class="comments anim-01"><span class="anim-01"><?= $forum_thread->forum_posts_number ?></span></a>
<h3><a href="./forums/<?= $forum->url_name ?>/<?= $forum_thread->id ?>/<?= $forum_thread->url_title ?>"><?= $forum_thread->title ?></a></h3>
<span class="meta"><a href="./articles/<?= $article->section->url_name ?>"><?= $forum_section->name ?></a> - <abbr class="timeago" title="<?= $forum_thread->created_at ?>"><?= $forum_thread->created_at ?></abbr></span>
</li>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
Everythings看起来很有效,但我有5个相同的论坛帖子:
HELLO
HELLO
HELLO
HELLO
HELOO
HELLO2
HELLo2
HELLO2
HELLO2
HELLO2
我想做的事情看起来像那样:
HELLO
HELLO2.
抱歉我的英文不好,谢谢你的回答!干杯
答案 0 :(得分:0)
执行:
<?php foreach(fetch('forum_threads', 'limit=5') as $forum_thread) : ?>
然后打印论坛帖子名称,然后:
<?php foreach(fetch('forums', 'limit=5') as $forum) : ?>
然后打印您的论坛网址,然后:
<?php foreach(fetch('forum_sections', 'limit=5') as $forum_section) : ?>
然后打印论坛部分名称。最后关闭所有的foreach。