Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing infinite scroll w/ a MySQL Database
    primarykey
    data
    text
    <p>I found a nice ajax/jquery infinite scroll plugin ( <a href="http://hycus.com/2011/03/15/infinite-scrolling-like-new-twitter-with-php-mysql-jquery/" rel="nofollow">http://hycus.com/2011/03/15/infinite-scrolling-like-new-twitter-with-php-mysql-jquery/</a> ) that I was able to mold well to my content, but I'm having one issue -- it only calls the loadmore.php script once. Let me show the code:</p> <p>In my index.php file:</p> <pre><code>&lt;script type="text/javascript"&gt; $(window).scroll(function(){ if($(window).scrollTop() == $(document).height() - $(window).height()){ $('div#loadmoreajaxloader').show(); $.ajax({ url: "loadmore.php?lastid=" + $(".postitem:last").attr("id"), success: function(html){ if(html){ $("#postswrapper").append(html); $('div#loadmoreajaxloader').hide(); }else{ $('div#loadmoreajaxloader').html('&lt;center&gt;No more posts to show.&lt;/center&gt;'); } } }); } }); &lt;/script&gt; </code></pre> <p>This section calls my loadmore.php file and sends it the id of the last post. This only works the first time I scroll to the bottom of the page, it loads the entries from loadmore.php but doesn't call loadmore.php again. My loadmore.php file has the following code:</p> <pre><code>&lt;?php include('./includes/config.php'); if($_GET['lastid']){ $query = 'SELECT * FROM db WHERE id &lt; "'.$_GET['lastid'].'" ORDER BY id DESC LIMIT 0,3'; $result = mysql_query($query); while ($rec = mysql_fetch_object($result)) { [SET MY VARS] ?&gt; [HTML &amp; PHP DISPLAYING MY POST] &lt;?php } } ?&gt; </code></pre> <p>The 3 posts that show up after the first ajax call come up perfectly, exactly the way I want them to show with the correct data. But I can't get the next 3 posts to show up after the first 3 show up.</p> <p>So if I have 5 posts by default on my index.php, I scroll to the bottom, ajax calls 3 more posts, they display perfectly, but nothing displays after that even though there are plenty of posts left to display. Where's my problem, ajax/jquery wizards?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload