1 00:00:00,720 --> 00:00:01,470 Welcome back. 2 00:00:02,220 --> 00:00:08,430 Now, what we need to do is that we need to fix something very important, which is a collision between 3 00:00:09,300 --> 00:00:14,250 the pagination as well as the the search. 4 00:00:14,250 --> 00:00:14,610 Here. 5 00:00:14,940 --> 00:00:16,350 Here, let me show you the problem. 6 00:00:16,980 --> 00:00:24,720 If I if I choose to search for a product here, for example, across and if I click on search, as you 7 00:00:24,720 --> 00:00:25,890 can see, I'm going to get an error here. 8 00:00:25,890 --> 00:00:29,760 It says undefined variable page number. 9 00:00:30,210 --> 00:00:33,510 The reason is because in the shop page. 10 00:00:34,620 --> 00:00:35,490 In the shop page. 11 00:00:36,060 --> 00:00:37,110 The page number. 12 00:00:37,110 --> 00:00:42,570 This page number only exists in case the user uses the pagination. 13 00:00:43,110 --> 00:00:49,590 So in order to fix this problem, we need to add pagination to also to do this issue, meaning that 14 00:00:49,590 --> 00:00:56,610 if users search for products, then these products that we will get from the database, we need to paginated 15 00:00:56,610 --> 00:00:56,880 them. 16 00:00:56,880 --> 00:01:00,510 We need to add them in, in separate pages. 17 00:01:00,990 --> 00:01:05,640 And to do this, we can simply copy a lot of code from the elsewhere. 18 00:01:05,640 --> 00:01:13,830 We can't copy this part and then we can't paste it here inside this use search here. 19 00:01:14,820 --> 00:01:18,000 And then we need also to copy this part. 20 00:01:19,400 --> 00:01:20,090 This part. 21 00:01:21,950 --> 00:01:23,420 And then we need to pace it here. 22 00:01:25,580 --> 00:01:28,280 However, we need to change a few things. 23 00:01:28,700 --> 00:01:33,110 We need to say select count as total records from. 24 00:01:33,860 --> 00:01:34,050 Uh. 25 00:01:34,220 --> 00:01:34,760 From. 26 00:01:34,760 --> 00:01:35,240 Uh. 27 00:01:36,700 --> 00:01:37,750 From projects. 28 00:01:38,440 --> 00:01:39,100 Where? 29 00:01:40,630 --> 00:01:41,200 Where. 30 00:01:43,810 --> 00:01:44,490 Right act. 31 00:01:45,700 --> 00:01:46,540 Underscore. 32 00:01:47,380 --> 00:01:50,380 Category is equal to a question mark. 33 00:01:52,770 --> 00:01:53,370 And. 34 00:01:56,070 --> 00:01:56,640 Protect. 35 00:01:59,110 --> 00:02:00,370 Underscore price. 36 00:02:02,730 --> 00:02:04,470 His smaller than or equal. 37 00:02:05,970 --> 00:02:09,210 QUESTION Mark And then we need to say here. 38 00:02:10,920 --> 00:02:11,670 Bind 39 00:02:14,400 --> 00:02:15,090 here, by the way. 40 00:02:15,100 --> 00:02:17,370 Statement, statement, not statement. 41 00:02:17,370 --> 00:02:17,640 One. 42 00:02:17,640 --> 00:02:18,630 Let me say statement. 43 00:02:19,530 --> 00:02:26,190 Statement of statement of statement of statement of intent to say bind firearm. 44 00:02:27,540 --> 00:02:31,680 And we need to bind the S.I. category. 45 00:02:31,890 --> 00:02:38,460 We need to say category, the glory and the price. 46 00:02:39,360 --> 00:02:43,860 However, we need to move the price of the category from here to the top. 47 00:02:43,860 --> 00:02:45,870 So I'm going to move them to the top here. 48 00:02:47,850 --> 00:02:54,960 And then the next step is that we need to get the record from here as well. 49 00:02:54,960 --> 00:02:56,070 We need to get this good. 50 00:02:57,920 --> 00:03:02,360 We need to get this good and display it and add it here. 51 00:03:03,140 --> 00:03:04,040 We need to arrive here. 52 00:03:04,940 --> 00:03:11,060 And lastly, we need to get the last part, which is which is this part. 53 00:03:12,050 --> 00:03:13,010 Which is this part. 54 00:03:13,640 --> 00:03:15,650 And then we need to paste it here. 55 00:03:18,360 --> 00:03:28,950 However, the the query is going to be select all from products limit offset total products page. 56 00:03:28,950 --> 00:03:33,540 But before we say limit, we need to say where we're. 57 00:03:37,570 --> 00:03:38,200 Project. 58 00:03:40,280 --> 00:03:41,060 Underscore. 59 00:03:41,600 --> 00:03:45,530 Category is equal to a question mark and. 60 00:03:47,480 --> 00:03:48,050 Product. 61 00:03:50,280 --> 00:03:54,150 Underscore rise smaller than or equal. 62 00:03:54,270 --> 00:03:55,110 Question mark. 63 00:03:55,620 --> 00:03:58,740 And again, we need to say statement. 64 00:04:01,420 --> 00:04:02,350 Statement. 65 00:04:03,470 --> 00:04:03,890 Do. 66 00:04:05,770 --> 00:04:08,440 And then bind Durham as I. 67 00:04:12,740 --> 00:04:13,580 Category. 68 00:04:17,010 --> 00:04:18,570 Category of rice. 69 00:04:22,350 --> 00:04:25,230 And then we need to remove this part. 70 00:04:25,230 --> 00:04:26,970 And also we need to remove. 71 00:04:28,000 --> 00:04:28,690 This part. 72 00:04:31,340 --> 00:04:32,240 This is an array. 73 00:04:35,190 --> 00:04:36,420 And we need to remove this part. 74 00:04:36,810 --> 00:04:40,680 So let me walk you through the code one more time, because now I think it's complicated. 75 00:04:41,740 --> 00:04:47,500 Here in case the user case user doesn't doesn't want to search for any product. 76 00:04:48,070 --> 00:04:52,840 What we need to do here in the case, we just need to use the pagination. 77 00:04:52,960 --> 00:04:54,460 We need to get all products. 78 00:04:55,630 --> 00:04:59,080 We need to give account which which means the all product. 79 00:04:59,090 --> 00:05:01,210 So the number of products that we have in the database. 80 00:05:02,440 --> 00:05:03,010 And then. 81 00:05:04,230 --> 00:05:06,570 We need to buy these products. 82 00:05:06,900 --> 00:05:10,880 Meaning that we need to divide them into separate pages. 83 00:05:10,890 --> 00:05:18,590 We need to add specific number of products in each and every single page in case user searches for the 84 00:05:18,610 --> 00:05:23,130 incase user, the user uses the search feature. 85 00:05:23,640 --> 00:05:27,600 Then we need first to use the pagination again when it is the page number. 86 00:05:28,050 --> 00:05:33,690 And then we need to get the category and the price and we need to get the count of the of these products. 87 00:05:33,690 --> 00:05:36,480 We don't want to get all the countable products. 88 00:05:36,840 --> 00:05:43,230 We just need to get the count of products that match this criteria. 89 00:05:43,800 --> 00:05:54,090 And then we just we just need to adhere by the initial concept, pagination variables, the total records 90 00:05:54,090 --> 00:05:56,040 per page, they offset all these things. 91 00:05:56,610 --> 00:06:02,400 And then we just need to execute the query which is select all from products. 92 00:06:02,400 --> 00:06:09,840 But this time we need to specify the criteria, which is the product category category and the product 93 00:06:09,840 --> 00:06:10,230 price. 94 00:06:10,650 --> 00:06:16,230 But we need to say limit of the total records per page because this is going to 95 00:06:19,170 --> 00:06:20,910 make the pagination work. 96 00:06:21,660 --> 00:06:23,040 And that's it here. 97 00:06:23,040 --> 00:06:26,970 By the way, we used the empty one and here is the empty two. 98 00:06:27,660 --> 00:06:35,820 And at the top we can, by the way, we can here also say is the empty one, is the empty one, and 99 00:06:35,820 --> 00:06:43,050 here is the empty one is the empty one is the one and here is the empty one because there is no collision 100 00:06:43,360 --> 00:06:46,290 if statement and the other one is else. 101 00:06:46,950 --> 00:06:49,740 So let me now save this should fix the problem. 102 00:06:50,460 --> 00:06:52,350 Now let me refresh and. 103 00:06:53,770 --> 00:06:58,060 Let me first go back to the homepage and then let me go. 104 00:06:58,750 --> 00:07:00,310 Go back again to the shop. 105 00:07:00,820 --> 00:07:07,120 Now in the shop, if I use the card, if I use the search feature, for example, if I say cards and 106 00:07:07,120 --> 00:07:10,360 then if I say if I change the price and click on search. 107 00:07:11,260 --> 00:07:17,080 As you can see, I'm going to get the products and I have pagination so I can go to page number two 108 00:07:17,770 --> 00:07:20,200 and it's going to display other products. 109 00:07:20,200 --> 00:07:27,520 If I say if I say, for example, shoes and increase this search, I'm going to get only shoes and they 110 00:07:27,520 --> 00:07:27,880 will. 111 00:07:27,970 --> 00:07:29,620 These shows are paginated. 112 00:07:30,310 --> 00:07:31,480 So they are paginated.