2 回答
TA贡献1875条经验 获得超5个赞
在你的代码中,你得到episode_num为$count_row,但它应该是没有行。试试下面的代码
$novel_list = new USER();
if (isset($_POST['page'])) {
$limit = $_POST['page']+3;
$stmt = $novel_list->runQuery("SELECT *
FROM posts
WHERE just_skpk='0'
ORDER BY id DESC
LIMIT $limit");
$stmt->execute();
if ($stmt->rowCount(0)) {
echo '<input class="hidden" id="pages" value="'.$limit.'"/>';
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$nv_name_split = str_replace('_', ' ', $row['novel_name']);
echo '<br><a data-pages="'.$limit.'" href="episode?novel='.$row['novel_name'].'&episode='.$row['episode_num'].'"><figure class="snip1253"><div class="image"><img width="100%"src="images/sneakpeaks/'.$row['sneak_peak'].'" alt="sample59"/></div><figcaption>'.
'<div class="date"><span class="day">'.$row['day'].'</span><span class="month">'.$row['month'].'</span></div><h3>Episode # '.$row['episode_num'].'</h3> <footer>
<div class="writer text-center"><i class="fa fa-book"> '.$nv_name_split.'</i></div>
<div class="love"><i class="fa fa-thumbs-up"></i>'.$row['likes'].'</div>
<div class="comments"><i class="fa fa-comments"></i>'.$row['comments'].'</div></footer></figure></a></figcaption><br><br>';
}
$stmt_count = $novel_list->runQuery("SELECT count(*) as cnt
FROM posts
WHERE just_skpk='0'");
$stmt_count->execute();
while ($rows = $stmt_count->fetch(PDO::FETCH_ASSOC)) {
$count_row = $rows['cnt'];
}
if ($limit < $count_row) {
echo '<form id="frm_more_post">
<center>
<button type="submit" class="form-control btn btn-load_more" id="frm_btn_more">Load More Posts</button>
</center>
</form>
<br>
<br>';
}else{
echo '<form id="frm_more_post">
<center>
<button type="submit" disabled class="disabled form-control btn btn-load_more" id="frm_btn_more">No More Posts</button>
</center>
</form>
<br>
<br>';
}
}else{
echo 0 ;
}
}
TA贡献1744条经验 获得超4个赞
我认为这是因为分页。在文件load_more.php中,您正在设置限制
$limit = $_POST['page']+3;
并在文件中,主.php
if ($limit < $count_row)
这是检查。
- 2 回答
- 0 关注
- 85 浏览
添加回答
举报