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 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata