【发布时间】:2018-11-14 12:50:40
【问题描述】:
我想打印特定类别的最后一篇文章
你能帮我写代码吗?
我想放在$record 手册上,例如:我放在"design" 上,只显示设计类别 中的最后一个帖子。
还有一件事:表 blog 与表 record 是分开的。
谢谢
<?php $category = $record ['record']; { ?>
<?php foreach($db->query("select * from blog where category = '$category' order by id desc") as $row){ ?>
<li>
<a href="<?php echo $row['image']; ?>">
<div class="gallery-item"><img src="<?php echo $row['image']; ?>" alt="<?php echo $row['title']; ?>"></div>
</a>
</li>
<?php } } ?>
【问题讨论】:
-
现在有什么问题以及您的预期输出是什么?
-
试试这个查询
select * from blog where category = '$category' order by id desc LIMIT 1 -
有人询问您现在得到的结果与预期结果相反。请问可以和cmets中的人互动吗?这样你就可以澄清你的问题。 @Ebi 你的问题不清楚。