Jump to content

Php Shopping Cart Tutorial


Recommended Posts



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 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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





Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...