Hova Posted August 1, 2014 Report Share Posted August 1, 2014 Hey, So i've just finished the PHP Shopping Cart tutorial and after i did that, i tried to change things up bit and tried to change the styling of the page. I changed the way the header and footer look and i was successful at doing so, however now i have a question and i need some help with that. I've just started learning PHP (1 week ago), so my knowledge is very limited at this point as you can imagine... I was wondering if it's possible to limit the number of products displaying per page and having pagination that dynamically updates whenever i insert or remove products... Is this something that's possible to do on this project? And if so, how can i do it? Tyvm in advance for your help, Bruno Feijão Quote Link to comment Share on other sites More sharing options...
falkencreative Posted August 2, 2014 Report Share Posted August 2, 2014 I'm moving cross country right now, so my time is unfortunately a bit limited. However, you might check out these two tutorials, which both show pagination: http://www.phpfreaks.com/tutorial/basic-pagination (simplest -- I'd look at this one first) http://www.killersites.com/community/index.php?/topic/3064-basic-php-system-view-edit-add-delete-records-with-mysqli/ (a little simpler, look at the "view-paginated.php" file) http://code.tutsplus.com/tutorials/how-to-paginate-data-with-php--net-2928 (a bit more complicated, with a pagination class) Basically, the key things you need to do: -- Do a query that gets the number of all products, and compare that against the number of products you want to show per page, to get the number of total paginated pages -- Instead of displaying all products, you want to retrieve specific products using LIMIT to determine where in the list of products you want to start from, and the number you need to retrieve -- You can set and retrieve which paginated page the visitor is on by using a $_GET variable in the URL Hope that gets you started? Quote Link to comment Share on other sites More sharing options...
Hova Posted August 2, 2014 Author Report Share Posted August 2, 2014 Thx for the links Ben. I'm going to go over them and see if i can create the pagination myself. Not easy just having started with PHP a week ago:P I'll let you know if i was successful or not:P Quote Link to comment Share on other sites More sharing options...
Hova Posted August 2, 2014 Author Report Share Posted August 2, 2014 One quick question, When i do understand how pagination works, and when i do get a working code, where do i insert it? In the Index.php file? Or on the view products file? Probably the dumbest question ever, but remember i'm new to php:P Thx, Bruno Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.