[英]how to skip iteration of while loop in associative array means we want to execute first ,second, fourth,fifth like this?
i am creating a CMS system. 我正在创建一个CMS系统。 if post is not published then it will not render in html otherwise show in html.
如果帖子未发布,则它将不会以html呈现,否则将以html显示。 So if I fetch a associative array from database "cms" then it has some published and unpublished post.
因此,如果我从数据库“ cms”中获取关联数组,则该数组具有一些已发布和未发布的帖子。 so how can i skip the unpublished posts and show only published posts in html.
因此,如何跳过未发布的帖子,仅显示html中的已发布帖子。
i have tried if condition 我已经尝试过条件
<!-- First Blog Post -->
<h2 style = "color:green;">
<?php echo $post_title ;?></a>
</h2>
<p class="lead">
by <?php echo $post_author ;?></a>
</p>
<p><span class="glyphicon glyphicon-time"></span><?php $post_date ?></p>
<hr>
<img class="img-responsive" src="images/<?php echo $post_image ;?>" alt="">
<hr>
<p><?php echo $post_content ?></p>
<a class="btn btn-primary" href="#">Read More <span class="glyphicon glyphicon-chevron-right"></span></a>
<hr>
**<?php } ?> **
**<?php } **// <!--loop ends here so that we can fetch 'n' no. of posts and displaying each post like below HTML -->
?>
</div>
if post == published then only show it in html otherwise don't show it. 如果发布==发布,则仅以html显示,否则不显示。
Check if post is not published at the start of the loop. 检查循环开始时是否未发布帖子。 then use the continue to skip through the rest of the loop.
然后使用继续跳过循环的其余部分。
while(items) { if(!$post->published) continue; // this part only runs if post is published }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.