Welcome back.
Now, what we need to do is that we need to fix something very important, which is a collision between
the pagination as well as the the search.
Here.
Here, let me show you the problem.
If I if I choose to search for a product here, for example, across and if I click on search, as you
can see, I'm going to get an error here.
It says undefined variable page number.
The reason is because in the shop page.
In the shop page.
The page number.
This page number only exists in case the user uses the pagination.
So in order to fix this problem, we need to add pagination to also to do this issue, meaning that
if users search for products, then these products that we will get from the database, we need to paginated
them.
We need to add them in, in separate pages.
And to do this, we can simply copy a lot of code from the elsewhere.
We can't copy this part and then we can't paste it here inside this use search here.
And then we need also to copy this part.
This part.
And then we need to pace it here.
However, we need to change a few things.
We need to say select count as total records from.
Uh.
From.
Uh.
From projects.
Where?
Where.
Right act.
Underscore.
Category is equal to a question mark.
And.
Protect.
Underscore price.
His smaller than or equal.
QUESTION Mark And then we need to say here.
Bind
here, by the way.
Statement, statement, not statement.
One.
Let me say statement.
Statement of statement of statement of statement of intent to say bind firearm.
And we need to bind the S.I. category.
We need to say category, the glory and the price.
However, we need to move the price of the category from here to the top.
So I'm going to move them to the top here.
And then the next step is that we need to get the record from here as well.
We need to get this good.
We need to get this good and display it and add it here.
We need to arrive here.
And lastly, we need to get the last part, which is which is this part.
Which is this part.
And then we need to paste it here.
However, the the query is going to be select all from products limit offset total products page.
But before we say limit, we need to say where we're.
Project.
Underscore.
Category is equal to a question mark and.
Product.
Underscore rise smaller than or equal.
Question mark.
And again, we need to say statement.
Statement.
Do.
And then bind Durham as I.
Category.
Category of rice.
And then we need to remove this part.
And also we need to remove.
This part.
This is an array.
And we need to remove this part.
So let me walk you through the code one more time, because now I think it's complicated.
Here in case the user case user doesn't doesn't want to search for any product.
What we need to do here in the case, we just need to use the pagination.
We need to get all products.
We need to give account which which means the all product.
So the number of products that we have in the database.
And then.
We need to buy these products.
Meaning that we need to divide them into separate pages.
We need to add specific number of products in each and every single page in case user searches for the
incase user, the user uses the search feature.
Then we need first to use the pagination again when it is the page number.
And then we need to get the category and the price and we need to get the count of the of these products.
We don't want to get all the countable products.
We just need to get the count of products that match this criteria.
And then we just we just need to adhere by the initial concept, pagination variables, the total records
per page, they offset all these things.
And then we just need to execute the query which is select all from products.
But this time we need to specify the criteria, which is the product category category and the product
price.
But we need to say limit of the total records per page because this is going to
make the pagination work.
And that's it here.
By the way, we used the empty one and here is the empty two.
And at the top we can, by the way, we can here also say is the empty one, is the empty one, and
here is the empty one is the empty one is the one and here is the empty one because there is no collision
if statement and the other one is else.
So let me now save this should fix the problem.
Now let me refresh and.
Let me first go back to the homepage and then let me go.
Go back again to the shop.
Now in the shop, if I use the card, if I use the search feature, for example, if I say cards and
then if I say if I change the price and click on search.
As you can see, I'm going to get the products and I have pagination so I can go to page number two
and it's going to display other products.
If I say if I say, for example, shoes and increase this search, I'm going to get only shoes and they
will.
These shows are paginated.
So they are paginated.