Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:18:53+00:00 2026-06-10T00:18:53+00:00

I’m making a query that pulls a lot of data from a sql table.

  • 0

I’m making a query that pulls a lot of data from a sql table. I’d like to implement an infinite scroll feature so that only 25 records or so are pulled at a time.

I’m having some trouble though.

This query gets called when a user scrolls down. jquery posts to php the last id of the last record that was put on the page;

//ie, this js pulls the id 
var last_order_number = $('.order_number_divs:last').attr('id');

//from this div
<div id="2476" class="order_number_divs">   1121310  </div>

I thought that if I selected two more results where the id was greater than the previous id on the page, I would definitely get the following two results. However, I get the same two results every time.

SELECT 
    id,
    order_number
    FROM sales_orders
    WHERE id > '$last_id'
    ORDER BY id ASC
    LIMIT 2

This is the jquery that runs the data through the template to populate the div. Since vkTemplate does not support appending, once it is done populating the div with the content, I remove the id of the just-populated div, and give the id to the div below it, so the next time there is a scroll, the content will go in that div.

$(window).scroll(function () {

    if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {



        var last_order_number = $('.order_number_divs:last').attr('id');

        console.log(last_order_number);
        $.ajax({
            type: "POST",
            async: false,
            url: "queries/privileged_search_more_content.php",
            data: "user=" + "<?=$_COOKIE['username']?>" + "&last_order_number=" + last_order_number,
            dataType: "json",
            success: function (data) {
                console.log(data);

                $('#INT-order_information_container').vkTemplate("templates/get_orders_initial_template.tmpl?" + <?=time()?> , data, function () {

                $('#INT-order_information_container').removeAttr('id');
                $('#template_div_next').removeAttr('id')
                                       .attr('id', 'INT-order_information_container');

                });
                console.log($.active);
            }
        });

    }
    });

Have you any ideas why the same two records are being pulled over and over?

Thanks much!

Also this scroll function I found seems to get invoked on up and down. But that’s a different question. Just saying so you know that I’m aware of at least that much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:18:55+00:00Added an answer on June 10, 2026 at 12:18 am

    vkTemplate does support appending. Take a look at the vkTemplate home page

    http://www.eslinstructor.net/vktemplate/

    There is menu item “Append Technique“.

    Another way to implement appending with vkTemplate is to customize this plugin. It’s simple: open code and find lines #94,102,117 https://github.com/vkiryukhin/vkTemplate/blob/master/vktemplate.js

    $(elm).empty().append(. . .)
    

    and remove empty() from this expression.

    Hope this helps,

    -Vadim

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.