So now what they need to do is that we need to connect the database and get these products.
And to do that, we need to we need to create a new file here in the server.
I'm going to click on the server and then I'm going to create a new file called Get.
Featured.
Products that BHP and then get featured products must connected to database.
Therefore we need to say BHP and then we need to say here include and then we need to include the connection
connection that BHP.
And now we need to create an email.
We need to create an HTTP query or query that's going to connect to the database and get these products.
And to do this, I'm going to use a con con because now we included this connection.
And this connection has a variable called connection, which connects to the database.
So here is that con and then I'm going to call a function called repair repair, and then it goes out
great.
So here's what I'm going to pass, is that I'm going to say select.
Select, because we need to get.
Select all we took it all from.
Products.
And.
You're going to say semi-colon.
So this is going to get all the products.
But we need to get only four products.
We need to get here for books.
Therefore, I'm going to say limit.
Limit for we need only four products.
And then I'm going to store this in a variable called S.
The empty statement.
And then I'm going to say your statement and then.
We don't need to pass anything.
So all we need to do is to execute this quiz or to execute this query, we need to say the empty and
then execute and then semicolon.
And then finally we need to return this to the caller or store it in a variable.
So I'm going to store this in a variable after saying here is the empty and then get.
Result.
And then I'm going to store the variable in I am going to store the result in a variable called feature.
Underscore products.
So this is the featured products and we can finally we can use this in the index.
So let me click on file and then Sable.
Now we need to include this get featured.
By the way, having your spelling mistake, Lainey, rename this file.
Get featured products.
So make sure that you don't have any typos or spelling mistakes.
Again here, featured products.
Now we can include the get features, featured products in the index and get these products, but we
need to find where the featured products are.
So the feature featured products are here.
And if I open this, you'll find that we have here for products hard coded and we don't want that.
Instead, we need to remove all products and keep only one code and then we can repeat that using a
loop.
This is where the power of BHP comes in.
The power of the power of BHP is that you don't have to repeat your cut.
You can type record once and repeat it using a loop.
Let me show you what I'm going to do.
So we need to find where is the first product.
So the first product is this.
Then it ends.
I think this is the end.
So this is the first product.
Therefore, we need to delete other products.
So I'm going to delete this second product.
This is the second product.
Remove it.
Allow me remove the third product, which is this.
Alamy remove also the last product and you need to be very, very careful while removing you.
Wouldn't want to remove something you would need.
And here at space.
Here.
This is the product lady save.
And let me make sure that I didn't break my coat.
Let me hear refresh and show you that.
Now, we should have only one block.
We have only one product.
Now we can use P3 to repeat the product because this get featured products will will return the products
will return all the products from the database.
So to to get all of the products we need you to say B2B.
You need to up in a B2B tag.
And then we need to include.
Include.
And what we want to include is that we need to include the of the featured.
So the featured get featured products is inside a file called server server and then for slash get featured
products.
So this is going to import this file.
Now this file has a.
As a variable called featured products.
And this featured products is an array.
This is an array.
So we can loop over this array.
Here.
I'm going to open a free tag.
I've been I'm going to say here.
I'm going to close it first and then I'm going to say while.
RA is equal to.
Get featured featured products.
Featured products.
Then we need to qualify.
Crinkled.
Fetch a sauce.
Then we need to open occasionally bracket.
Just open the close it.
Just open it.
And then at the end we need to close it.
We need you to say BHP.
They don't need the closet.
Closet occasionally bracket in between.
We need now to display the products.
So instead of displaying the hard coded.
Code here text.
We can remove this now and then we can here say B2B and then B2B and then in between we need we can
say echo and then echo what?
A.R. And then semicolon and the name of the column that contains the name of the product.
So the name of the column is products product name, remember.
Product name, product name, product category, description, image.
So we need to say product underscoring for the price.
We need to say here.
We need to keep the dollar sign and then we need to say B2B, then B2B and then eco raw.
Product price.
And for the image here.
The image.
We need to say here.
Forest lush.
BHP.
Echo.
We're all.
Products.
Image.
And then semicolon and that's it.
So we have the product.
Let me make sure that we have everything we have the.
Image, image, the name and the price.
So let me now save and let me make sure that I don't have any thing wrong.
Let me now.
So let me refresh.
And as you can see, I'm going to get the same exact products here.
But the difference is now I got the products from the database.
I'm not getting the products from from hard coded text.
I'm getting the products from the database by using this as you can see how how powerful this is, because
I'm just using a loop and that loop will keep displaying the new products over and over and over again
without the need of typing these things.
So as you can see now, we have these products being displayed here.