dongyi9082 2014-07-10 12:32
浏览 28
已采纳

如何在下一页显示成功记录? [关闭]

I have a page for displaying items from database limited to 20 records the other records should be displayed on the next page, 20 items per page, and so on here is the code for displaying the last 20 items.

<?php
require_once '../Model/Connexion.php';
$c = new Connexion();
$results = $c->query("select * from annonce limit 20 ");
$rows = $c->resultset();  ?>
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>Ads display</title>
</head>
<body> 
  <div id="Wraper">
     <div id="Middle">
        <div class="Left">  
           <div class="Content FCKeditor">        
              <div class="Pagination">
                <span class="Fright">Page 1
                  <a href="page.php?page=<?php echo $number?>"> | Next </a></span>
                <span class="Fleft">Showing 1 to 20  jobs of <?php echo $c->rowCount()?></span> 
              </div>
              <div class="Joblist">
                <?php foreach($rows as $r) { ?>
                   <p class="Title">
                <span class="Ref"></span>
                   <a href="details.php?id=<?php echo($r['id_annonce']) ?>">
                <?php echo($r['poste']); ?></a></p>
                   <p class="Date"><span class="Fright"><?php echo($r['type_contrat']); ?></span>
                <span><a href="client.php" class="Sectorbtn"><?php echo($r['client']); ?></a></span></p>
                   <p style="text-align:justify;"><?php echo($r['desc_annonce']); ?></p>
                   <p class="More">
                     <a href="details.php?id=<?php echo($r['id_annonce']) ?>">View more</a>
                   </p>
                <?php }?>
              </div>

             <div class="Pagination">
                <span class="Fright">Page 1<a href="page.php?page=<?php echo $number?>"> | Next </a></span>
                <span class="Fleft">Showing 1 to 20  jobs of <?php echo $c->rowCount()?></span> 
              </div>
           </div>
        </div>
     </div>
  </div>
</body>
</html>

I wish to display the others itemps on an ordred pages could you help me ?

  • 写回答

1条回答 默认 最新

  • douhuiyan2772 2014-07-10 13:35
    关注

    Basically, you need 2 requests :

    A request to count the total number of jobs :

    SELECT COUNT(*) FROM annonce
    

    A request to give you X jobs starting from (n-1)*X to be included in the nth page. Example for the 4th page :

    SELECT * FROM annonce LIMIT 60, 20
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制