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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 MATLAB APP 制作出现问题
  • ¥15 wannier复现图像时berry曲率极值点与高对称点严重偏移
  • ¥15 利用决策森林为什么会出现这样·的问题(关键词-情感分析)
  • ¥15 DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI[/untitled30_war_e
  • ¥15 使用deepspeed训练,发现想要训练的参数没有梯度
  • ¥15 寻找一块做为智能割草机的驱动板(标签-stm32|关键词-m3)
  • ¥15 信息管理系统的查找和排序
  • ¥15 基于STM32,电机驱动模块为L298N,四路运放电磁传感器,三轮智能小车电磁组电磁循迹(两个电机,一个万向轮),怎么用读取的电磁传感器信号表示小车所在的位置
  • ¥15 如何解决y_true和y_predict数据类型不匹配的问题(相关搜索:机器学习)
  • ¥15 PB中矩阵文本型数据的总计问题。