<i id='Zsb0F'><tr id='Zsb0F'><dt id='Zsb0F'><q id='Zsb0F'><span id='Zsb0F'><b id='Zsb0F'><form id='Zsb0F'><ins id='Zsb0F'></ins><ul id='Zsb0F'></ul><sub id='Zsb0F'></sub></form><legend id='Zsb0F'></legend><bdo id='Zsb0F'><pre id='Zsb0F'><center id='Zsb0F'></center></pre></bdo></b><th id='Zsb0F'></th></span></q></dt></tr></i><div id='Zsb0F'><tfoot id='Zsb0F'></tfoot><dl id='Zsb0F'><fieldset id='Zsb0F'></fieldset></dl></div>

    • <bdo id='Zsb0F'></bdo><ul id='Zsb0F'></ul>

    1. <legend id='Zsb0F'><style id='Zsb0F'><dir id='Zsb0F'><q id='Zsb0F'></q></dir></style></legend>
      <tfoot id='Zsb0F'></tfoot>

      <small id='Zsb0F'></small><noframes id='Zsb0F'>

    2. 如何为无限滚动的查询结果分页?

      How to paginate query results for Infinite Scroll?(如何为无限滚动的查询结果分页?)

      <small id='7iTmq'></small><noframes id='7iTmq'>

      <legend id='7iTmq'><style id='7iTmq'><dir id='7iTmq'><q id='7iTmq'></q></dir></style></legend>

      • <bdo id='7iTmq'></bdo><ul id='7iTmq'></ul>
            <tfoot id='7iTmq'></tfoot>
          • <i id='7iTmq'><tr id='7iTmq'><dt id='7iTmq'><q id='7iTmq'><span id='7iTmq'><b id='7iTmq'><form id='7iTmq'><ins id='7iTmq'></ins><ul id='7iTmq'></ul><sub id='7iTmq'></sub></form><legend id='7iTmq'></legend><bdo id='7iTmq'><pre id='7iTmq'><center id='7iTmq'></center></pre></bdo></b><th id='7iTmq'></th></span></q></dt></tr></i><div id='7iTmq'><tfoot id='7iTmq'></tfoot><dl id='7iTmq'><fieldset id='7iTmq'></fieldset></dl></div>

                <tbody id='7iTmq'></tbody>
                本文介绍了如何为无限滚动的查询结果分页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个使用 2 个 PHP 文件和一个 MySql 数据库的示例页面,我正在尝试在其上使用 jQuery 无限滚动.如何从数据库加载下一组数据?例如,我的图片数据库中有 100 条记录,我想显示 20 条,然后滚动显示下 20 条.

                I have a sample page that uses 2 PHP files and a MySql database, and I'm trying to use jQuery infinite scroll on it. How can I load the next group of data from database? For example, I have 100 records in my pictures database, and I want to show 20, and then the next 20 after some scrolling.

                这是我目前的核心:

                index.php

                <?php
                ob_start();
                require_once('images.html'); 
                ob_end_flush();
                ?>
                

                images.html

                <!doctype html>
                <html lang="en">
                <head>
                  <meta charset="utf-8" />
                  <title> trata tata</title>
                  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
                  <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
                  <link rel="stylesheet" href="./css/style.css" />
                   <!-- scripts at bottom of page -->
                </head>
                <body class="demos ">
                  <nav id="site-nav">
                    <h1><a href="./index.html">ole tu jest HOME</a></h1>
                    <h2>Menu 1</h2>
                    <ul class="docs-list">
                        <li><a href="../docs/intro.html">11111111</a>
                    </ul>
                    <h2>Menu 2</h2>
                    <ul class="demos-list">
                        <li><a href="../demos/basic-single-column.html">222222222</a>
                        <li class="current"><a href="#content">3333333333</a></li>
                    </ul>
                  </nav> <!-- #site-nav -->
                
                  <section id="content">
                     <h1>cos tam ....</h1>
                     <div id="container" class="clearfix">
                     <?php
                     // Make a MySQL Connection
                     mysql_connect("localhost", "root", "") or die(mysql_error());
                     mysql_select_db("test") or die(mysql_error());
                
                     // Retrieve all the data from the "test " table
                     $result = mysql_query("SELECT * FROM foto")
                     or die(mysql_error());  
                
                     // store the records of the "TABLENAME" table into $row array and loop through
                     while ( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ) {
                
                     // Print out the contents of the entry 
                
                     //echo "details: ".$row['id'];
                     echo '<div class="box photo col3">';
                     echo "<img src="".$row['src']."" alt="wwwwww" />";
                     echo '</div>';
                     }
                     ?>
                     </div> <!-- #container -->
                
                     <script src="./js/jquery-1.7.1.min.js"></script>
                     <script src="./jquery.masonry.min.js"></script>
                     <script>
                       $(function(){
                         var $container = $('#container');
                         $container.imagesLoaded( function(){
                           $container.masonry({
                             itemSelector : '.box'
                           });
                         });
                
                       });
                     </script>
                     <footer id="site-footer">
                       szaki <a href="http://desandro.com">sdfsdfdsfsdf</a>
                     </footer>
                
                  </section> <!-- #content -->
                
                </body>
                </html>
                

                <!-- #container --><script src="./js/jquery-1.7.1.min.js"></script><script src="./jquery.masonry.min.js"></script><脚本>$(函数(){var $container = $('#container');$container.imagesLoaded( 函数(){$container.masonry({itemSelector : '.box'});});});<footer id="site-footer">szaki <a href="http://desandro.com">sdfsdfdsfsdf</a></页脚></节><!-- #content -->

                推荐答案

                您需要将 LIMIT 添加到您的查询中.MySQL 手册中的示例:

                SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15

                Here, 5 is the starting offset, and 10 is the amount of rows you want to fetch.

                这里,5 是起始偏移量,10 是您要获取的行数.

                For the client-side you'll need the infinite scroll jQuery plugin.

                这篇关于如何为无限滚动的查询结果分页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                <small id='6e6Tq'></small><noframes id='6e6Tq'>

                  <tbody id='6e6Tq'></tbody>
                <legend id='6e6Tq'><style id='6e6Tq'><dir id='6e6Tq'><q id='6e6Tq'></q></dir></style></legend>

                      <bdo id='6e6Tq'></bdo><ul id='6e6Tq'></ul>
                      <tfoot id='6e6Tq'></tfoot>
                        <i id='6e6Tq'><tr id='6e6Tq'><dt id='6e6Tq'><q id='6e6Tq'><span id='6e6Tq'><b id='6e6Tq'><form id='6e6Tq'><ins id='6e6Tq'></ins><ul id='6e6Tq'></ul><sub id='6e6Tq'></sub></form><legend id='6e6Tq'></legend><bdo id='6e6Tq'><pre id='6e6Tq'><center id='6e6Tq'></center></pre></bdo></b><th id='6e6Tq'></th></span></q></dt></tr></i><div id='6e6Tq'><tfoot id='6e6Tq'></tfoot><dl id='6e6Tq'><fieldset id='6e6Tq'></fieldset></dl></div>