我遇到了问题,希望通过下一个按钮在1页以上显示我的新闻 并且我的代码是:
<?php
$stmt = $DB_con->prepare('SELECT userID, userName, userProfession, userPic, postDate FROM tbl_users ORDER BY userID DESC');
$stmt->execute();
$foundData = false;
if($stmt->rowCount() > 0)
{
$foundData = true;
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
?>
<ul class="col-md-12 blog-posts post-list">
<li class="blog-post clearfix">
<div class="post-media">
<a href="">
<img src="user_images/<?php echo $row['userPic']; ?>" class="img-responsive" alt="Construction HTML Template"/>
</a>
</div><!-- .post-media end -->
<div class="icon-container">
<i class="fa fa-calendar"></i>
</div>
<div class="post-body">
<div class="post-date">
echo '<p>'. mds_date("Y/m/d", strtotime($row['postDate']), 0 ).'</p>'; ?>
</div>
<a href="">
<h3><?php echo $userName." "; ?></h3>
</a>
<p>
<?php echo $userProfession." "; ?>
</p>
</div><!-- .post-body end -->
</li><!-- .blog-post end -->
<?php
}
}
else
{
if(isset($foundData) && !$foundData){
echo " no data found ." ;
}
}
?>
</ul>
答案 0 :(得分:0)
如果我是你,我会用ajax来做,因为ajax可以让一切看起来更好而且你可以在不刷新页面的情况下做到这一点查看文档
https://api.jquery.com/category/ajax/
但您可以使用
LIMIT $startpage, $per_page;
希望这有帮助