Infinite scroll (General)

by Andy, Thursday, November 05, 2015, 16:44 (2879 days ago)

Ok here's another one...

I'm trying to implement an infinite scroll technique, this is to try and cut the time it takes to display the posts, so that the select is not having to query the whole '***_entries' table every time

As a temporary fix, I first edited the query in to have a limit of 2000, as my users generally do not click more than 20 pages back.

$result=mysqli_query($connid, "SELECT id, tid FROM ( SELECT * FROM ".$db_settings['forum_table']." ORDER BY id DESC LIMIT 2000 ) sub...

This works in terms of speed but not it's not really satisfactory.

So I'm trying to implement 'Infinite Ajax Scroll' - it's getting there but hitting a brick wall now. I've correctly added the script code and link, and here's where I've got to in the php:

$limit = 50;
$start = ($page * $limit) - $limit;
$sql = "SELECT * FROM ".$db_settings['forum_table']." ORDER BY id DESC"; 
$result=mysqli_query($connid, "SELECT id, tid FROM (".$sql." LIMIT $start,$limit) sub WHERE pid = 0 ORDER BY sticky DESC, ".$db_thread_order." ".$descasc." ") or raise_error('database_error',mysqli_error());

IAS is just stating 'no more posts' when scrolling to the bottom of the screen because I presume that the variable $start is not updating. I can't get my head round how or where $result will update if the page is scrolled down to the bottom, and where the code should go in the template or in the .inc file.

Would you be able to shed any light on this please, or indeed have you thought about implementing an infinite scroll option in mlf?

In summary all I am trying to do is to select and load say 50 entries from the database, rather than having to select all of them every time. When users are flicking between boards it does make a big difference.

Thanks in advance.

Complete thread:

 RSS Feed of thread