So here I'm going to say project super page and this total.
Records.
Per page.
Total Records Bear Page is the number of products that you choose.
This is a this is a variable that you choose.
I'm going to say eight.
I want eight, only eight products page and then I'm going to say offset this.
Now the tricky part offset.
So the offset is going to be equal to the page number.
Page.
Number minus one multiplied by the total records per page total records, period.
This is going to return the offset.
Why would we want an offset?
Offset is important in order to be able to apply it to the pagination, as do the concept of pagination.
And then we want to create a variable called previous page.
So the previous.
Page.
So the previous page is going to be equal to page number.
Minus one.
And we next page.
So that next page is going to be equal to page number.
Last one.
So what are these?
These are these buttons.
Remember here at the bottom, we have mixed and previous and mixed.
And in order to go back, we need to create a value called previous.
And in order to go forward, we need to say next, we need to get a variable called next, which is
going to increase the number of pages.
Our next we want.
DuKiNG it.
If I am called a Jason of Jason's, which is going to be equal to two.
And next, we want to calculate something important, which is the total number of pages.
So how can we get the total number of pages?
Well, since we have the total request per page and we have the total records we can and we have the
offset as well, we can calculate the total number of pages.
So the total number.
Of.
Pages is going to be equal to seal because we don't want to get a point.
We want we want we only want integers.
We don't want a decimal number.
So the total number of pages is going to be equal to the total total records.
The total product divided by the total records which.
Total records per page.
Don't tell.
Recursively.
It's pretty simple.
If you divide the total record by the total acres per page, you are going to get the total number of
pages that you need to display.
Lastly, we need to get all products.
Now we are done with this.
This is the concept of pagination, which is getting the total number of pages, the offset.
The next page, the previous page, the adjacent.
And the total number of pages.
Lastly, we need to get the products now get all products.
Products.
But this time I'm not going to display all of them.
This time I'm going to divide them to do these pages.
To do that, I got to get to the total number of pages.
So let's now here to get a new statement.
I'm going to say statement.
Now, let's say statement two is going to be equal to con and then prepare and then select all.
Silver.
All.
From.
Products.
But we need to limit we need to use the limit by the offset.
Offset.
And we need to limit also by the total record speech total.
Total.
Records.
Burbage.
And lastly, we need to execute and get the results.
We need to say here is the key to execute.
And.
We need to say we need to store the result in a variable called products.
Now we have the product.
So the product is going to be equal to statement to.
So you think to get results, get results, and we are going to go pretty, pretty simple.
There's nothing difficult about this.
Now, let's work on the pagination itself in the bottom.
See the bottom here in the bottom.
What I'm going to do is that I am going to here say below this, below this we need to add BHP code.
We need to say.
Here to the previous.
We need to add a class to disable that class if if we are in the first page.
So here inside this class, I'm going to add BHP and then I'm going to check the number of pages.
I'm going to say if page number is smaller than one, then I'm going to say Echo.
Echo and then I'm going to echo last call disabled this April disable disabled which is a bootstrap
and then semicolon and then inside that and say the attack itself, inside this attack or any of this
attacking a new line.
And you have to be very careful because this is tricky and then this in a new line.
So inside this attack, we need to activate the atria.
So the edge is going to be equal to BHP.
BHP and then if.
If.
Page number.
Is smaller than one.
If page number is smaller or equal to one, then we need to echo.
Echo.
Hashtag, because we cannot it cannot take the user anywhere because the page number is smaller than
one.
You cannot go previous small.
You cannot go up to page zero.
There is no zero.
And then don't forget to add to close the page.
But we need to do also add else else else.
If the page number is not smaller than zero, we need to display the link that will allow the user to
go back.
So else I'm going to say Echo.
Echo.
So what do we want to echo?
We want to echo.
Question mark and then page underscore number.
Is equal to is equal to that.
And then we concatenated the page number, page number minus one, which is the previous you can use
the previous page that we used.
But I'm going I'm going to use here page number minus one, and that's it inside.
You just need to log this.
Here.
You need to close this display previous.
That's it.
So this is for the previous.
This is for the previous speech.
Let's now work on the next bit because it's a little tricky and then I'm going to work on the numbers.
So for the next.
We need to do the same.
So here in this class, I'm going to say HP and then all right, that between we need to check the page
number.
I'm going to say if page number, page number is greater than or equal, the total number of pages,
total number of page.
If this is the last page, then we need to echo it or disable.
This.
Able because the user cannot go further.
This is their last page.
Else else we need to display the link.
So in the tag here.
Here.
There's nothing else here in the attack.
We need to display a link.
So here in the attack I'm going to say P2P and then first I'm going to check again.
I'm going to do the if statement.
I'm going to see if page number.
Page number is greater than or equal.
The total.
Greater than or equal the total number of pages.
Then we need to echo.
Echo.
Hashtag.
Because we need to deactivate this page or disable this page.
Else.
L.
What we want to do is that we need again to echo the be the link.
So I'm going to say echo and then page number.
Question mark.
Page number.
Page underscore number is equal to and then got.
Then we concatenate the next page.
So we concatenate the page number plus one.
Page number plus one.
Events.
I mean, don't forget the same cover.
Pretty simple.
And then finally, we just say, next.
That's it.
So this is.
These are the.
The next on previous pages.
Now, let's work on the numbers here.
We shouldn't be displaying we shouldn't be displaying all numbers.
We should only display two numbers and then we display dots.
So for the first number, for page number one, we just need to say we just need to display the link.
So here in the entry, we just need to say page.
Underscore number is equal to one because the page number is always going to be one.
For page number two, we need to say a question mark and then page number is equal to two, it's always
going to be two.
Then more than this, I'm not going to be displaying three, four or five, six.
I'm not going to do this.
Instead, I'm going to display here dots, dots.
And then the user can always use the next the next button to go to page number three and then four and
then five, etc..
But we need here to add a code in order to display the correct page number.
To do this, we need to check the page number first.
We need to say B, b and then.
If.
Page number.
Is greater than or equal three.
Because at this point, it's greater than or equal three.
Then here.
Caleb Brackett.
I think really bracket and in between we need to say.
We need to say a da da da.
And then we need to next to it, we need to display the the the number.
We need to display the actual number of the page.
So this da da da that indicates that there are many, many pages, pages between to and the page that
the user is currently browsing.
So I'm going to say here, I'm going to copy this line and then I'm going to pasted below.
And then instead of displaying da da da da here, I'm going to say Beach B and then I'm going to encode
the correct number, the correct page number.
So here I'm going to say echo.
Page number and four.
Don't forget the semicolon.
And for the entry, if we need again to say beach B and then.
Echo.
Question mark.
PAGE The number is equal to that page number.
That's it.
We are done.
Let me now save and let's head on over to the browser.
So let me go to the browser and let me now refresh.
So now as you can see, what I'm going to get is that I'm going to get only eight products.
One, two, three, four, four, five, six, seven, eight.
And now I have a previous, previous now is disabled because now I'm at page number one.
If I go to page number two here, it's going to say page number is two.
And the previous page, the previous button is active was activated.
If I click on next.
If I click on next, I will not be able to go through next because I don't have many other products.
I only have 16 products, but I can go back, I can click on previous and it should take me to the next
to the to the previous page.
If it doesn't, then we need to add we need to add brackets here.
So here I need to add brackets.
Let me add here brackets and also here brackets because.
Because here I think this could affect the girls.
So we win.
When we add a number or subtract, we need to add in brackets.
Let me try one more time.
So I'm going to go back and refresh and now it should work.
Now, if I click on Previous, it's going to take me to the previous page.
If I click on Next, it's going to take me to the next page.
So as you can see and you can again control the number of products that you have per page.
For example, here, if I say if I say total records per page, if I say one, if I say only one and
save and refresh, I will get only one product page, product per page.
So as you can see now, I'm going to get only one product per page.
And if I click on next, I'm going to get to the next page.
If I click on next, I'm going to get to the next page.
And here is going to display the page number.
For example, for here, if I click on it, it's going to take me to page number four.
If you click on Next, it's going to take me to page number five.
Number six.
Number seven.
Number eight.
Etc..
And if I click on one, I'm going to get back to page number one.
And I know I can't go to page number here because obviously there's no page.
There's no page that is number zero.
We start from one.
So this is how it works.
And I'm going to be displaying eight products SPEAR which.