在coulmns中显示帖子 [英] Displaying posts in coulmns

查看:82
本文介绍了在coulmns中显示帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此代码中,我将在三列中显示帖子。如果我有三个或三个以上的帖子,但是如果我只有一个或两个帖子,它们会在桌子上传播,那么它是否有效。我是否可以通过哪种方式限制发布仅适合它的帖子。如果我只有一个帖子要显示,那么表格应该有一个帖子和两个空格。



In this code I am displaying posts in three columns. It works well if I have three or more than 3 posts but if I have only one post or two, they spread through out table, Is there any way by which I can restrict a post to take place only meant for it. If I have only one post to display , table should have one post and two empty spaces.

<table>
<tr>
<?php do { //horizontal looper?>
<td>
<div><h2><?php echo $row['title']; ?></h2></div>          
<div><p><?php echo $row['body']; ?></p></div>
<img src='<?php echo $row['pic']; ?>'>
<div><p><?php echo $row['about']; ?></p></div>
</td>
<?php
$row = $query->fetch(PDO::FETCH_ASSOC);
if (!isset($nested_List)) {
$nested_List= 1;
}
if (isset($row) && is_array($row) && $nested_List++%3==0) {
echo "</tr><tr>";
}
} while ($row); //end horizontal looper 
?>
</table>

推荐答案

row [' title']; ?> < / h2 < span class =code-keyword>> < / div >
< div > < p > <? php echo
row['title']; ?></h2></div> <div><p><?php echo


row [' body']; ?> < / p < span class =code-keyword>> < / div >
< img src =' <?php echo
row['body']; ?></p></div> <img src='<?php echo


row [' pic']; > '>
< div > < p > <? php echo
row['pic']; ?>'> <div><p><?php echo


这篇关于在coulmns中显示帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆