How to add pagination to a website?


#1

Hello. I had a question for myself. if we have a movie website and on the first page we have 20 movies but when we want to include in the new movie, as a matter of fact that this new movie we introduced to go to the second page and on the first page there are still 20 movies. I hope someone helps me.


#2

Welcome to the forums, @wordone45. It sounds like you are looking to add a pagination feature to your website. Is your site coded in straight html/css or is it build with one of the CMS's such as WordPress?


#3

my site is built with html / css so you're saying that all this leaves out of pagination?


#4

So how to do a pagination like that ?


#5

Typically sites with pagination have a database which stores all of the information. This is then printed out to a page. when you query the database you get a set of results and you can limit how many are returned and when you start from.

Typically there is only 1 actual page but the variable on the end changes to change which results are shown

www.example.com/results.php?page=1

etc

the page=1 bit is just a variable used so the code knows where to start from. there is a bit more to it than that but if you aren't familiar with queries it prob won't make a lot of sense.

Each time the page is called the database is checked so if you have added new records it will appear on the first page and another record drops onto the second page etc. You don't have to do this manually as it will do this automatically.

The problem you have is if you have a static html page with a list it has to be changed manually and will become pretty difficult to manage as you will have to have numerous .html pages and move bits of text from one list to the next.

hope that makes sense


#6

That makes sense to me, but I need something to understand


#7

What would that be?


#8

as an example


#9

Example: Whenever you see a list of items, such as in a store, and see a row of numbers at the bottom, like:

Prev 1 2 3 4 Next

... then the next page will be supplied by a database when you click on the page number. Do a search of anything and you'll see Google doing this at the bottom of the search results. That is an example of a database creating the pagination.

With a static html/css site, you'll create those links at the bottom of the site, but each page number will be a hand-linked < a href > link. Every time you create a new page of content, you'll need to go back and add that new page at the bottom of all the other pages to include it and re-number all the pages. Very, very bad headache to do this.


#10

Thank you man . but I did what you were saying, the problem is on the front page we have 20 photos when adding another photo the first page was left with 20 photos and pictures we posted to go to page 2. How about this?


#11

You will post photos 21-40 on page 2. Simple. But as I wrote in my example, it will get really bad linking all these pages at the bottom the more you add pages.

Any time you find yourself with 20 or more identical elements, you should move to a database-driven website and save yourself a ton of work.


closed #12

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.