1 00:00:00,570 --> 00:00:04,170 So now what they need to do is that we need to connect the database and get these products. 2 00:00:04,740 --> 00:00:10,980 And to do that, we need to we need to create a new file here in the server. 3 00:00:12,450 --> 00:00:17,490 I'm going to click on the server and then I'm going to create a new file called Get. 4 00:00:19,860 --> 00:00:20,700 Featured. 5 00:00:23,440 --> 00:00:29,980 Products that BHP and then get featured products must connected to database. 6 00:00:30,040 --> 00:00:39,430 Therefore we need to say BHP and then we need to say here include and then we need to include the connection 7 00:00:40,810 --> 00:00:43,480 connection that BHP. 8 00:00:45,310 --> 00:00:47,910 And now we need to create an email. 9 00:00:48,310 --> 00:00:56,260 We need to create an HTTP query or query that's going to connect to the database and get these products. 10 00:00:56,710 --> 00:01:04,840 And to do this, I'm going to use a con con because now we included this connection. 11 00:01:04,840 --> 00:01:09,670 And this connection has a variable called connection, which connects to the database. 12 00:01:10,330 --> 00:01:18,250 So here is that con and then I'm going to call a function called repair repair, and then it goes out 13 00:01:18,910 --> 00:01:19,250 great. 14 00:01:20,050 --> 00:01:23,500 So here's what I'm going to pass, is that I'm going to say select. 15 00:01:24,370 --> 00:01:25,960 Select, because we need to get. 16 00:01:27,220 --> 00:01:32,020 Select all we took it all from. 17 00:01:35,240 --> 00:01:36,620 Products. 18 00:01:39,450 --> 00:01:40,110 And. 19 00:01:42,390 --> 00:01:43,980 You're going to say semi-colon. 20 00:01:43,980 --> 00:01:45,450 So this is going to get all the products. 21 00:01:46,020 --> 00:01:48,420 But we need to get only four products. 22 00:01:48,420 --> 00:01:49,710 We need to get here for books. 23 00:01:49,740 --> 00:01:50,970 Therefore, I'm going to say limit. 24 00:01:52,500 --> 00:01:55,230 Limit for we need only four products. 25 00:01:56,640 --> 00:02:01,020 And then I'm going to store this in a variable called S. 26 00:02:02,210 --> 00:02:03,920 The empty statement. 27 00:02:04,700 --> 00:02:09,800 And then I'm going to say your statement and then. 28 00:02:11,990 --> 00:02:13,280 We don't need to pass anything. 29 00:02:13,280 --> 00:02:18,950 So all we need to do is to execute this quiz or to execute this query, we need to say the empty and 30 00:02:18,950 --> 00:02:21,740 then execute and then semicolon. 31 00:02:22,250 --> 00:02:27,530 And then finally we need to return this to the caller or store it in a variable. 32 00:02:27,530 --> 00:02:33,290 So I'm going to store this in a variable after saying here is the empty and then get. 33 00:02:35,240 --> 00:02:35,850 Result. 34 00:02:37,020 --> 00:02:42,860 And then I'm going to store the variable in I am going to store the result in a variable called feature. 35 00:02:45,160 --> 00:02:47,980 Underscore products. 36 00:02:50,570 --> 00:02:56,780 So this is the featured products and we can finally we can use this in the index. 37 00:02:57,380 --> 00:03:00,100 So let me click on file and then Sable. 38 00:03:00,530 --> 00:03:03,170 Now we need to include this get featured. 39 00:03:03,830 --> 00:03:07,070 By the way, having your spelling mistake, Lainey, rename this file. 40 00:03:08,680 --> 00:03:12,220 Get featured products. 41 00:03:13,000 --> 00:03:16,270 So make sure that you don't have any typos or spelling mistakes. 42 00:03:16,900 --> 00:03:19,000 Again here, featured products. 43 00:03:19,420 --> 00:03:26,380 Now we can include the get features, featured products in the index and get these products, but we 44 00:03:26,380 --> 00:03:28,870 need to find where the featured products are. 45 00:03:29,260 --> 00:03:31,690 So the feature featured products are here. 46 00:03:32,640 --> 00:03:40,530 And if I open this, you'll find that we have here for products hard coded and we don't want that. 47 00:03:40,990 --> 00:03:49,140 Instead, we need to remove all products and keep only one code and then we can repeat that using a 48 00:03:49,140 --> 00:03:49,470 loop. 49 00:03:50,250 --> 00:03:53,970 This is where the power of BHP comes in. 50 00:03:54,660 --> 00:03:58,830 The power of the power of BHP is that you don't have to repeat your cut. 51 00:03:59,190 --> 00:04:02,340 You can type record once and repeat it using a loop. 52 00:04:02,820 --> 00:04:04,470 Let me show you what I'm going to do. 53 00:04:05,040 --> 00:04:07,290 So we need to find where is the first product. 54 00:04:07,300 --> 00:04:08,550 So the first product is this. 55 00:04:09,520 --> 00:04:10,870 Then it ends. 56 00:04:12,500 --> 00:04:13,640 I think this is the end. 57 00:04:14,150 --> 00:04:15,230 So this is the first product. 58 00:04:16,010 --> 00:04:18,350 Therefore, we need to delete other products. 59 00:04:18,350 --> 00:04:20,450 So I'm going to delete this second product. 60 00:04:22,240 --> 00:04:23,230 This is the second product. 61 00:04:23,650 --> 00:04:24,250 Remove it. 62 00:04:25,360 --> 00:04:27,880 Allow me remove the third product, which is this. 63 00:04:30,860 --> 00:04:36,350 Alamy remove also the last product and you need to be very, very careful while removing you. 64 00:04:36,350 --> 00:04:38,120 Wouldn't want to remove something you would need. 65 00:04:39,720 --> 00:04:41,340 And here at space. 66 00:04:43,030 --> 00:04:43,360 Here. 67 00:04:43,750 --> 00:04:45,880 This is the product lady save. 68 00:04:45,880 --> 00:04:48,350 And let me make sure that I didn't break my coat. 69 00:04:48,670 --> 00:04:50,290 Let me hear refresh and show you that. 70 00:04:51,190 --> 00:04:53,650 Now, we should have only one block. 71 00:04:53,650 --> 00:04:55,060 We have only one product. 72 00:04:55,570 --> 00:05:04,660 Now we can use P3 to repeat the product because this get featured products will will return the products 73 00:05:04,660 --> 00:05:06,730 will return all the products from the database. 74 00:05:07,960 --> 00:05:11,310 So to to get all of the products we need you to say B2B. 75 00:05:11,320 --> 00:05:13,750 You need to up in a B2B tag. 76 00:05:13,750 --> 00:05:15,460 And then we need to include. 77 00:05:16,590 --> 00:05:17,310 Include. 78 00:05:18,000 --> 00:05:24,330 And what we want to include is that we need to include the of the featured. 79 00:05:24,390 --> 00:05:33,660 So the featured get featured products is inside a file called server server and then for slash get featured 80 00:05:33,660 --> 00:05:34,080 products. 81 00:05:34,920 --> 00:05:36,660 So this is going to import this file. 82 00:05:36,660 --> 00:05:39,390 Now this file has a. 83 00:05:40,550 --> 00:05:43,100 As a variable called featured products. 84 00:05:43,550 --> 00:05:45,700 And this featured products is an array. 85 00:05:45,710 --> 00:05:46,940 This is an array. 86 00:05:47,970 --> 00:05:49,560 So we can loop over this array. 87 00:05:49,560 --> 00:05:49,890 Here. 88 00:05:50,640 --> 00:05:51,120 Here. 89 00:05:51,210 --> 00:05:53,040 I'm going to open a free tag. 90 00:05:54,960 --> 00:05:56,040 I've been I'm going to say here. 91 00:05:57,660 --> 00:06:00,750 I'm going to close it first and then I'm going to say while. 92 00:06:17,720 --> 00:06:20,690 RA is equal to. 93 00:06:22,200 --> 00:06:25,740 Get featured featured products. 94 00:06:29,680 --> 00:06:31,390 Featured products. 95 00:06:33,180 --> 00:06:33,930 Then we need to qualify. 96 00:06:33,930 --> 00:06:34,440 Crinkled. 97 00:06:34,650 --> 00:06:36,420 Fetch a sauce. 98 00:06:40,850 --> 00:06:42,680 Then we need to open occasionally bracket. 99 00:06:42,710 --> 00:06:44,120 Just open the close it. 100 00:06:44,130 --> 00:06:44,780 Just open it. 101 00:06:45,260 --> 00:06:46,850 And then at the end we need to close it. 102 00:06:46,850 --> 00:06:48,410 We need you to say BHP. 103 00:06:50,180 --> 00:06:51,030 They don't need the closet. 104 00:06:51,800 --> 00:06:54,380 Closet occasionally bracket in between. 105 00:06:54,380 --> 00:06:56,510 We need now to display the products. 106 00:06:57,140 --> 00:07:00,590 So instead of displaying the hard coded. 107 00:07:02,480 --> 00:07:03,800 Code here text. 108 00:07:04,220 --> 00:07:12,560 We can remove this now and then we can here say B2B and then B2B and then in between we need we can 109 00:07:12,560 --> 00:07:14,370 say echo and then echo what? 110 00:07:14,390 --> 00:07:22,820 A.R. And then semicolon and the name of the column that contains the name of the product. 111 00:07:22,820 --> 00:07:28,520 So the name of the column is products product name, remember. 112 00:07:30,240 --> 00:07:33,630 Product name, product name, product category, description, image. 113 00:07:34,260 --> 00:07:38,760 So we need to say product underscoring for the price. 114 00:07:38,760 --> 00:07:39,780 We need to say here. 115 00:07:40,260 --> 00:07:49,380 We need to keep the dollar sign and then we need to say B2B, then B2B and then eco raw. 116 00:07:55,190 --> 00:07:57,230 Product price. 117 00:08:00,570 --> 00:08:02,580 And for the image here. 118 00:08:02,580 --> 00:08:03,120 The image. 119 00:08:04,590 --> 00:08:05,670 We need to say here. 120 00:08:07,830 --> 00:08:08,560 Forest lush. 121 00:08:12,090 --> 00:08:12,690 BHP. 122 00:08:16,670 --> 00:08:17,240 Echo. 123 00:08:19,360 --> 00:08:19,770 We're all. 124 00:08:22,280 --> 00:08:22,820 Products. 125 00:08:24,770 --> 00:08:25,340 Image. 126 00:08:27,120 --> 00:08:30,420 And then semicolon and that's it. 127 00:08:31,920 --> 00:08:33,250 So we have the product. 128 00:08:33,280 --> 00:08:35,310 Let me make sure that we have everything we have the. 129 00:08:36,610 --> 00:08:39,880 Image, image, the name and the price. 130 00:08:40,780 --> 00:08:44,980 So let me now save and let me make sure that I don't have any thing wrong. 131 00:08:44,980 --> 00:08:45,430 Let me now. 132 00:08:46,690 --> 00:08:47,830 So let me refresh. 133 00:08:49,580 --> 00:08:52,640 And as you can see, I'm going to get the same exact products here. 134 00:08:53,120 --> 00:08:57,110 But the difference is now I got the products from the database. 135 00:08:57,110 --> 00:09:03,410 I'm not getting the products from from hard coded text. 136 00:09:03,740 --> 00:09:10,280 I'm getting the products from the database by using this as you can see how how powerful this is, because 137 00:09:10,280 --> 00:09:16,580 I'm just using a loop and that loop will keep displaying the new products over and over and over again 138 00:09:16,820 --> 00:09:19,130 without the need of typing these things. 139 00:09:19,130 --> 00:09:23,120 So as you can see now, we have these products being displayed here.