第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

php 而循環(huán)不顯示 15 行之后的行

php 而循環(huán)不顯示 15 行之后的行

PHP
猛跑小豬 2022-08-05 10:04:13
你好,我有兩個(gè)文件,一個(gè)文件包含主要帖子,第二個(gè)文件包含加載更多帖子代碼以下是主文件的代碼,但在這個(gè)文件中,我有一個(gè)問(wèn)題,我必須循環(huán)php中的所有mysql行,我可以使用while循環(huán)來(lái)做到這一點(diǎn),但是當(dāng)我嘗試這樣做時(shí),我會(huì)得到所有行,但在15行之后,它只顯示那些在15行之后的行,比如只有16行我的主要.php代碼while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {    $nv_name_split = str_replace('_', ' ', $row['novel_name']);    echo '<br><a 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>';}?><?php $stmt_count = $novel_list->runQuery("SELECT episode_num                                     FROM posts                                     WHERE just_skpk='0'");$stmt_count->execute();while ($rows = $stmt_count->fetch(PDO::FETCH_ASSOC)) {    $count_row = $rows['episode_num'];}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>'; }這是我load_more.php代碼,我使用ajax發(fā)布帖子限制
查看完整描述

2 回答

?
慕田峪4524236

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超5個(gè)贊

在你的代碼中,你得到episode_num為$count_row,但它應(yīng)該是沒(méi)有行。試試下面的代碼


$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 ;

    }

}


查看完整回答
反對(duì) 回復(fù) 2022-08-05
?
慕無(wú)忌1623718

TA貢獻(xiàn)1744條經(jīng)驗(yàn) 獲得超4個(gè)贊

我認(rèn)為這是因?yàn)榉猪?yè)。在文件load_more.php中,您正在設(shè)置限制

$limit = $_POST['page']+3;

并在文件中,主.php

if ($limit < $count_row)

這是檢查。


查看完整回答
反對(duì) 回復(fù) 2022-08-05
  • 2 回答
  • 0 關(guān)注
  • 97 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)