Now we have pagination on the main index page let's add it to the admin index too.
First let's copy these two lines from the index page where we are creating a paginate to and getting
the records from the database.
Then in the abdomen index we can replace this line where we're getting all the records
instead of four records per page.
They'll just to demonstrate how it still works by just changing this argument.
Let's have six per page instead.
Then let's just copy the pagination links from the index page.
And paste them at the bottom of the abdomen index
for the previous link.
We need to change the hsf from the roots index to the abdomen index and the same for the next link.
In the browser.
Now our admin index has pagination with fewer pages as we have more records per page.
We've repeated ourselves again with the pagination links.
So let's extract this out into an include file.
We'll create a new file in the includes folder in the root kalid pagination Doug P. HP
and we'll paste the pagination links in here.
We can't have a hard coded link in here though.
What we need to do is get the current address of whatever page including this file in.
We can get the path of the current page using the request.
You are right elements of the server super global.
So let's add a variable that contains this and then replace the path in the previous link with this
variable and also the next link.
Next we need to replace the pagination links in the admin index.
With this new include using two dots to go down to the includes folder in the root.
On the first page of the admin index the next link works going to the next page including the admen
folder.
However if I click next again the page value in the query string has been repeated and if I click it
again it's repeated again.
This is because the request you value includes the query string.
So when we create the previous r next link were pending this to a value that already contains the query
string which is why it's repeated so we want this value without the query string.
We can use this string tokenizer function for that.
This function splits the string into smaller ones based on a delimiter.
So if for example we pass in the request you are in value and a question mark as the delimiter.
This function will return everything before the first question mark.
The other parts can be obtained by subsequent calls of this function but we only need to call it once
as we only need the first part.
If the delimiter the question mark isn't found then it simply returns the entire string.
So let's call this function passing in the request.
You are a value and the question mark as the delimiter as the query string in a U R L is everything.
After the first question mark character.
So now when I click Next it works and subsequent clicks on the navigation links.
I'll work as expected.
Now in the main index page in The Root.
We can replace these pagination links with the new.
Include.
And these work as before.