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 6696805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:23:05+00:00 2026-05-26T06:23:05+00:00

I’m trying to figure out a good method for loading records sequentially using some

  • 0

I’m trying to figure out a good method for loading records sequentially using some pagination.

Upon load the page will query the db and grab the most recent 5 records and show a link ‘show more’ at the end of these. When this link is clicked it should post again and retrieve the next 5 records, so in this sense the records will be loaded only adhoc.

I guess this is somehow similar to pagination but without the counter of pages, just the ‘next’. The current code we have is inline javascript which jquery posts to a php script and returns an array which then gets appended. Good thing is that html is not

Should my initial query grab the count of all records in the db for pagination?

Any reference in particular that will help me accomplish this?

The code below has one problem, when ‘Showmore’ is clicked it only loads one more record instead of 3 (num var)

var num = 3;
                var i =0,j=0;
                var total;
                var sm;

                function fun(sm){                        

                      $.post('select1.php?id=2',{},function(count){
                        total = count;
                        });

                      $.post('select1.php?id=1',{num:num},function(data)
                        {
                        if(num == total)
                        {
                            $('#show').hide();
                            $('#show1').html('<p>No more images found!</p>');
                        } 

                       var arr = data.split('/');

                    //alert(arr.length);

                    if(sm){j=sm};

                    for(i=j;i<(arr.length-1);i++)
                    {
                    //alert(arr[i]);
                       var p = arr[i].split('.');
                    //alert(p[1]);
                       $('#imggal').append('<a href="page3.php?file='+arr[i]+'"><img src="upload/small'+arr[i]+'" title ='+arr[i+1]+' border="0"></img></a><br><span style="display:block;font-size:12px;color:blue;letter-spacing:-1px">'+arr[i+2]+'<br>'+arr[i+1]+'</span><br></br').fadeIn('slow');
                       i=i+2;
                    }
                    });
                }

                fun();

                $(document).ready(function(){

                    $('#showmore').click(function(e){
                       //e.preventDefault();


                        j=num*3;

                        num++;
                        //alert(num);
                        //$('#imggal').html('');
                        fun(j);

                    });
                });
  • 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-05-26T06:23:06+00:00Added an answer on May 26, 2026 at 6:23 am

    I can’t post comments yet so I will attempt to answer with limited information here. I am going to make some assumptions.

    • You have your select query ordering by something to keep your result sequential between calls
    • You don’t want to remove previous items when you load more, you literally want to keep displaying new items until you run out of items in the database to add

    With those assumptions, an easy way to determine if you have more items to display is to keep track of an offset along with your number per request. As an example…

    If you want to display 5 items per ‘show more’ requests you would

    • Start offset at 0
    • Start num at 5
    • Request num+1, but only display num
    • If result set is > num, you can show more, as you know for sure more exist
    • If result set is <= num, you can’t show any more, you ran out of data
    • If you ‘show more’, increase your offset by num

    With this method, you have no idea of your total items in your database, but you always know if you have more to show.

    Again, you would need to limit and orderby your select query in the database to make this work. IE for mysql

    select filename, thumbnail, id from image_table order by id limit OFFSET, NUM
    

    OFFSET and NUM are from your .post

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

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.