I have this code which is part of an AJAX function where 5 rows are added to $opslaglimit
each time the user reaches the bottom of the page.
$opslaglimit = 5;
$opslag = $db->prepare("SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.id LIMIT $opslaglimit");
I want to make a function, so I can display a message to the user when there are no rows left to collect from the database that matches the query.
I know this can be achieved by making an other query without the LIMIT and then compare the count. This just seems like a bit of code and I want to hear if any of you knows a more simple way.
Thanks
You could "hack around it" by checking if the number of results returned are less than the limit requested. That would mean you are at the end. However, you'll get a false positive once out of each N for limit. Just a QUICK hack. I'll offer a real solution later if needed. :)