I have a coupon code site. On some category pages I'm limiting it to display only 50 coupons as there are potentially 1000's of coupons for each category. I don't display them all as it would be hard on the server, and the browser will hang. Is it possible to lazy load more coupons as the user keeps scrolling down?
The only lazy load plugins I've found are for images. Anything out there that will work with PHP and loading data from a MySQL db?
Any help is appreciated. Thanks!
You will definitely need javascript or jquery for this. Just use an onScroll event when the scroll-bar is for example at 75% call a php-file using AJAX, pass 2 parameters for the query. Using the SQL Limit you need to set the start-indicator and the number of rows you want to collect: SELECT * FROM tbl_coupons LIMIT 50,20
You can use let the php output the html you want to use and insert the html straight into the Dom or if you want to parse the data using JS you can use *json_encode* to create a json-object from an array of rows.
do you mean like this one http://www.webresourcesdepot.com/dnspinger/
Personally I would do it with ajax, as soon as the browser detects a scroll it start to load the next coupons from the db, once they are loaded it will display them. I'm not aware of a script that would do this automatically, but it's not difficult to code with jquery.
Another idea would be to cache the coupons page, assuming they don't change every second it could be a feasible solution.