1 00:00:00,360 --> 00:00:03,570 So here I'm going to say project super page and this total. 2 00:00:05,280 --> 00:00:06,170 Records. 3 00:00:07,270 --> 00:00:07,990 Per page. 4 00:00:08,320 --> 00:00:13,370 Total Records Bear Page is the number of products that you choose. 5 00:00:13,390 --> 00:00:16,620 This is a this is a variable that you choose. 6 00:00:16,630 --> 00:00:17,380 I'm going to say eight. 7 00:00:17,380 --> 00:00:22,110 I want eight, only eight products page and then I'm going to say offset this. 8 00:00:22,120 --> 00:00:25,270 Now the tricky part offset. 9 00:00:26,310 --> 00:00:30,510 So the offset is going to be equal to the page number. 10 00:00:31,580 --> 00:00:32,180 Page. 11 00:00:33,300 --> 00:00:44,510 Number minus one multiplied by the total records per page total records, period. 12 00:00:44,910 --> 00:00:46,320 This is going to return the offset. 13 00:00:46,620 --> 00:00:49,230 Why would we want an offset? 14 00:00:49,230 --> 00:00:56,640 Offset is important in order to be able to apply it to the pagination, as do the concept of pagination. 15 00:00:57,300 --> 00:01:03,740 And then we want to create a variable called previous page. 16 00:01:03,750 --> 00:01:04,680 So the previous. 17 00:01:08,060 --> 00:01:08,570 Page. 18 00:01:10,250 --> 00:01:13,220 So the previous page is going to be equal to page number. 19 00:01:15,980 --> 00:01:16,810 Minus one. 20 00:01:22,000 --> 00:01:23,710 And we next page. 21 00:01:24,220 --> 00:01:27,430 So that next page is going to be equal to page number. 22 00:01:28,150 --> 00:01:28,720 Last one. 23 00:01:29,350 --> 00:01:30,220 So what are these? 24 00:01:30,760 --> 00:01:32,180 These are these buttons. 25 00:01:32,200 --> 00:01:35,560 Remember here at the bottom, we have mixed and previous and mixed. 26 00:01:35,920 --> 00:01:40,530 And in order to go back, we need to create a value called previous. 27 00:01:40,540 --> 00:01:45,340 And in order to go forward, we need to say next, we need to get a variable called next, which is 28 00:01:45,340 --> 00:01:46,990 going to increase the number of pages. 29 00:01:48,140 --> 00:01:49,360 Our next we want. 30 00:01:50,750 --> 00:01:51,500 DuKiNG it. 31 00:01:53,100 --> 00:02:00,600 If I am called a Jason of Jason's, which is going to be equal to two. 32 00:02:01,680 --> 00:02:08,910 And next, we want to calculate something important, which is the total number of pages. 33 00:02:09,270 --> 00:02:11,190 So how can we get the total number of pages? 34 00:02:11,220 --> 00:02:17,730 Well, since we have the total request per page and we have the total records we can and we have the 35 00:02:17,730 --> 00:02:20,340 offset as well, we can calculate the total number of pages. 36 00:02:20,820 --> 00:02:23,340 So the total number. 37 00:02:25,140 --> 00:02:25,650 Of. 38 00:02:27,360 --> 00:02:32,880 Pages is going to be equal to seal because we don't want to get a point. 39 00:02:33,390 --> 00:02:35,940 We want we want we only want integers. 40 00:02:35,940 --> 00:02:38,100 We don't want a decimal number. 41 00:02:38,730 --> 00:02:45,420 So the total number of pages is going to be equal to the total total records. 42 00:02:45,420 --> 00:02:50,550 The total product divided by the total records which. 43 00:02:51,760 --> 00:02:55,510 Total records per page. 44 00:02:58,600 --> 00:02:59,320 Don't tell. 45 00:03:01,480 --> 00:03:02,080 Recursively. 46 00:03:02,170 --> 00:03:03,190 It's pretty simple. 47 00:03:03,190 --> 00:03:11,140 If you divide the total record by the total acres per page, you are going to get the total number of 48 00:03:11,140 --> 00:03:13,420 pages that you need to display. 49 00:03:15,070 --> 00:03:17,060 Lastly, we need to get all products. 50 00:03:17,080 --> 00:03:18,220 Now we are done with this. 51 00:03:18,790 --> 00:03:24,040 This is the concept of pagination, which is getting the total number of pages, the offset. 52 00:03:24,310 --> 00:03:27,370 The next page, the previous page, the adjacent. 53 00:03:28,650 --> 00:03:30,090 And the total number of pages. 54 00:03:30,660 --> 00:03:34,890 Lastly, we need to get the products now get all products. 55 00:03:36,050 --> 00:03:36,640 Products. 56 00:03:36,650 --> 00:03:39,140 But this time I'm not going to display all of them. 57 00:03:39,530 --> 00:03:44,420 This time I'm going to divide them to do these pages. 58 00:03:44,570 --> 00:03:47,660 To do that, I got to get to the total number of pages. 59 00:03:48,170 --> 00:03:51,290 So let's now here to get a new statement. 60 00:03:51,290 --> 00:03:52,290 I'm going to say statement. 61 00:03:52,310 --> 00:04:03,500 Now, let's say statement two is going to be equal to con and then prepare and then select all. 62 00:04:05,580 --> 00:04:06,180 Silver. 63 00:04:09,520 --> 00:04:10,000 All. 64 00:04:11,570 --> 00:04:12,110 From. 65 00:04:14,840 --> 00:04:15,650 Products. 66 00:04:18,550 --> 00:04:24,340 But we need to limit we need to use the limit by the offset. 67 00:04:24,850 --> 00:04:25,720 Offset. 68 00:04:28,140 --> 00:04:34,800 And we need to limit also by the total record speech total. 69 00:04:37,360 --> 00:04:38,020 Total. 70 00:04:40,020 --> 00:04:41,360 Records. 71 00:04:42,490 --> 00:04:43,120 Burbage. 72 00:04:48,450 --> 00:04:52,350 And lastly, we need to execute and get the results. 73 00:04:52,350 --> 00:04:57,210 We need to say here is the key to execute. 74 00:04:59,940 --> 00:05:00,420 And. 75 00:05:01,620 --> 00:05:05,790 We need to say we need to store the result in a variable called products. 76 00:05:06,060 --> 00:05:06,990 Now we have the product. 77 00:05:06,990 --> 00:05:09,960 So the product is going to be equal to statement to. 78 00:05:11,810 --> 00:05:18,800 So you think to get results, get results, and we are going to go pretty, pretty simple. 79 00:05:19,400 --> 00:05:20,930 There's nothing difficult about this. 80 00:05:22,130 --> 00:05:25,340 Now, let's work on the pagination itself in the bottom. 81 00:05:25,730 --> 00:05:27,980 See the bottom here in the bottom. 82 00:05:28,670 --> 00:05:39,850 What I'm going to do is that I am going to here say below this, below this we need to add BHP code. 83 00:05:39,860 --> 00:05:40,730 We need to say. 84 00:05:43,250 --> 00:05:44,510 Here to the previous. 85 00:05:44,510 --> 00:05:49,460 We need to add a class to disable that class if if we are in the first page. 86 00:05:49,940 --> 00:05:55,610 So here inside this class, I'm going to add BHP and then I'm going to check the number of pages. 87 00:05:55,610 --> 00:06:02,690 I'm going to say if page number is smaller than one, then I'm going to say Echo. 88 00:06:04,580 --> 00:06:13,740 Echo and then I'm going to echo last call disabled this April disable disabled which is a bootstrap 89 00:06:13,940 --> 00:06:21,500 and then semicolon and then inside that and say the attack itself, inside this attack or any of this 90 00:06:21,500 --> 00:06:22,610 attacking a new line. 91 00:06:24,350 --> 00:06:29,270 And you have to be very careful because this is tricky and then this in a new line. 92 00:06:29,270 --> 00:06:32,150 So inside this attack, we need to activate the atria. 93 00:06:32,690 --> 00:06:35,000 So the edge is going to be equal to BHP. 94 00:06:35,870 --> 00:06:38,540 BHP and then if. 95 00:06:39,620 --> 00:06:40,040 If. 96 00:06:41,380 --> 00:06:42,280 Page number. 97 00:06:43,960 --> 00:06:47,650 Is smaller than one. 98 00:06:48,130 --> 00:06:52,270 If page number is smaller or equal to one, then we need to echo. 99 00:06:53,050 --> 00:06:53,620 Echo. 100 00:06:55,050 --> 00:07:01,860 Hashtag, because we cannot it cannot take the user anywhere because the page number is smaller than 101 00:07:01,860 --> 00:07:02,100 one. 102 00:07:02,730 --> 00:07:04,800 You cannot go previous small. 103 00:07:05,100 --> 00:07:08,910 You cannot go up to page zero. 104 00:07:08,910 --> 00:07:10,050 There is no zero. 105 00:07:11,580 --> 00:07:14,730 And then don't forget to add to close the page. 106 00:07:17,070 --> 00:07:21,630 But we need to do also add else else else. 107 00:07:21,640 --> 00:07:27,810 If the page number is not smaller than zero, we need to display the link that will allow the user to 108 00:07:27,810 --> 00:07:28,530 go back. 109 00:07:29,220 --> 00:07:31,800 So else I'm going to say Echo. 110 00:07:33,490 --> 00:07:34,060 Echo. 111 00:07:34,570 --> 00:07:35,930 So what do we want to echo? 112 00:07:35,950 --> 00:07:36,940 We want to echo. 113 00:07:38,450 --> 00:07:42,500 Question mark and then page underscore number. 114 00:07:43,530 --> 00:07:46,770 Is equal to is equal to that. 115 00:07:47,340 --> 00:07:56,580 And then we concatenated the page number, page number minus one, which is the previous you can use 116 00:07:56,580 --> 00:07:59,970 the previous page that we used. 117 00:07:59,970 --> 00:08:06,090 But I'm going I'm going to use here page number minus one, and that's it inside. 118 00:08:06,120 --> 00:08:08,880 You just need to log this. 119 00:08:15,090 --> 00:08:15,450 Here. 120 00:08:15,470 --> 00:08:18,290 You need to close this display previous. 121 00:08:18,300 --> 00:08:18,750 That's it. 122 00:08:19,110 --> 00:08:20,370 So this is for the previous. 123 00:08:21,120 --> 00:08:22,500 This is for the previous speech. 124 00:08:22,950 --> 00:08:28,410 Let's now work on the next bit because it's a little tricky and then I'm going to work on the numbers. 125 00:08:28,830 --> 00:08:30,000 So for the next. 126 00:08:30,980 --> 00:08:31,960 We need to do the same. 127 00:08:31,970 --> 00:08:40,070 So here in this class, I'm going to say HP and then all right, that between we need to check the page 128 00:08:40,070 --> 00:08:40,340 number. 129 00:08:40,340 --> 00:08:50,120 I'm going to say if page number, page number is greater than or equal, the total number of pages, 130 00:08:50,930 --> 00:08:51,740 total number of page. 131 00:08:51,830 --> 00:08:58,400 If this is the last page, then we need to echo it or disable. 132 00:09:00,230 --> 00:09:00,830 This. 133 00:09:01,730 --> 00:09:03,820 Able because the user cannot go further. 134 00:09:03,830 --> 00:09:05,030 This is their last page. 135 00:09:05,810 --> 00:09:10,820 Else else we need to display the link. 136 00:09:11,330 --> 00:09:12,680 So in the tag here. 137 00:09:12,680 --> 00:09:12,920 Here. 138 00:09:12,920 --> 00:09:15,260 There's nothing else here in the attack. 139 00:09:15,260 --> 00:09:16,340 We need to display a link. 140 00:09:16,340 --> 00:09:21,830 So here in the attack I'm going to say P2P and then first I'm going to check again. 141 00:09:21,830 --> 00:09:23,660 I'm going to do the if statement. 142 00:09:23,670 --> 00:09:25,550 I'm going to see if page number. 143 00:09:27,450 --> 00:09:30,570 Page number is greater than or equal. 144 00:09:31,730 --> 00:09:32,570 The total. 145 00:09:34,640 --> 00:09:40,070 Greater than or equal the total number of pages. 146 00:09:40,610 --> 00:09:41,870 Then we need to echo. 147 00:09:43,280 --> 00:09:43,670 Echo. 148 00:09:44,750 --> 00:09:45,410 Hashtag. 149 00:09:45,440 --> 00:09:49,940 Because we need to deactivate this page or disable this page. 150 00:09:50,360 --> 00:09:50,990 Else. 151 00:09:52,910 --> 00:09:53,420 L. 152 00:09:56,600 --> 00:10:01,580 What we want to do is that we need again to echo the be the link. 153 00:10:02,210 --> 00:10:04,620 So I'm going to say echo and then page number. 154 00:10:04,640 --> 00:10:05,300 Question mark. 155 00:10:05,300 --> 00:10:05,990 Page number. 156 00:10:07,520 --> 00:10:13,100 Page underscore number is equal to and then got. 157 00:10:13,610 --> 00:10:15,530 Then we concatenate the next page. 158 00:10:16,280 --> 00:10:19,430 So we concatenate the page number plus one. 159 00:10:20,570 --> 00:10:21,800 Page number plus one. 160 00:10:22,850 --> 00:10:23,360 Events. 161 00:10:23,370 --> 00:10:24,890 I mean, don't forget the same cover. 162 00:10:26,780 --> 00:10:27,380 Pretty simple. 163 00:10:27,410 --> 00:10:29,240 And then finally, we just say, next. 164 00:10:29,510 --> 00:10:29,900 That's it. 165 00:10:30,170 --> 00:10:30,720 So this is. 166 00:10:30,740 --> 00:10:32,150 These are the. 167 00:10:32,810 --> 00:10:34,640 The next on previous pages. 168 00:10:34,670 --> 00:10:36,670 Now, let's work on the numbers here. 169 00:10:36,680 --> 00:10:39,440 We shouldn't be displaying we shouldn't be displaying all numbers. 170 00:10:39,440 --> 00:10:43,310 We should only display two numbers and then we display dots. 171 00:10:43,700 --> 00:10:50,900 So for the first number, for page number one, we just need to say we just need to display the link. 172 00:10:51,320 --> 00:10:55,370 So here in the entry, we just need to say page. 173 00:10:57,080 --> 00:11:02,180 Underscore number is equal to one because the page number is always going to be one. 174 00:11:03,200 --> 00:11:11,750 For page number two, we need to say a question mark and then page number is equal to two, it's always 175 00:11:11,750 --> 00:11:12,410 going to be two. 176 00:11:13,130 --> 00:11:17,270 Then more than this, I'm not going to be displaying three, four or five, six. 177 00:11:17,270 --> 00:11:18,050 I'm not going to do this. 178 00:11:18,090 --> 00:11:22,040 Instead, I'm going to display here dots, dots. 179 00:11:22,040 --> 00:11:28,490 And then the user can always use the next the next button to go to page number three and then four and 180 00:11:28,490 --> 00:11:29,510 then five, etc.. 181 00:11:30,380 --> 00:11:40,670 But we need here to add a code in order to display the correct page number. 182 00:11:40,880 --> 00:11:44,540 To do this, we need to check the page number first. 183 00:11:44,540 --> 00:11:46,880 We need to say B, b and then. 184 00:11:48,350 --> 00:11:48,730 If. 185 00:11:49,910 --> 00:11:50,360 If. 186 00:11:51,880 --> 00:11:52,720 Page number. 187 00:11:56,230 --> 00:11:58,180 Is greater than or equal three. 188 00:11:58,300 --> 00:12:01,060 Because at this point, it's greater than or equal three. 189 00:12:01,870 --> 00:12:02,620 Then here. 190 00:12:04,680 --> 00:12:05,460 Caleb Brackett. 191 00:12:13,860 --> 00:12:17,900 I think really bracket and in between we need to say. 192 00:12:20,530 --> 00:12:22,120 We need to say a da da da. 193 00:12:22,840 --> 00:12:28,080 And then we need to next to it, we need to display the the the number. 194 00:12:28,420 --> 00:12:30,700 We need to display the actual number of the page. 195 00:12:31,150 --> 00:12:39,310 So this da da da that indicates that there are many, many pages, pages between to and the page that 196 00:12:39,310 --> 00:12:40,900 the user is currently browsing. 197 00:12:41,470 --> 00:12:48,100 So I'm going to say here, I'm going to copy this line and then I'm going to pasted below. 198 00:12:48,640 --> 00:12:57,100 And then instead of displaying da da da da here, I'm going to say Beach B and then I'm going to encode 199 00:12:57,100 --> 00:12:59,620 the correct number, the correct page number. 200 00:13:00,160 --> 00:13:01,330 So here I'm going to say echo. 201 00:13:03,710 --> 00:13:07,770 Page number and four. 202 00:13:07,790 --> 00:13:08,840 Don't forget the semicolon. 203 00:13:09,440 --> 00:13:13,700 And for the entry, if we need again to say beach B and then. 204 00:13:15,700 --> 00:13:16,300 Echo. 205 00:13:18,360 --> 00:13:19,230 Question mark. 206 00:13:20,160 --> 00:13:27,780 PAGE The number is equal to that page number. 207 00:13:28,650 --> 00:13:29,190 That's it. 208 00:13:29,610 --> 00:13:30,390 We are done. 209 00:13:31,830 --> 00:13:34,050 Let me now save and let's head on over to the browser. 210 00:13:35,130 --> 00:13:38,040 So let me go to the browser and let me now refresh. 211 00:13:39,490 --> 00:13:43,450 So now as you can see, what I'm going to get is that I'm going to get only eight products. 212 00:13:43,450 --> 00:13:47,020 One, two, three, four, four, five, six, seven, eight. 213 00:13:47,590 --> 00:13:53,530 And now I have a previous, previous now is disabled because now I'm at page number one. 214 00:13:54,010 --> 00:13:57,850 If I go to page number two here, it's going to say page number is two. 215 00:13:58,300 --> 00:14:02,650 And the previous page, the previous button is active was activated. 216 00:14:03,310 --> 00:14:04,750 If I click on next. 217 00:14:05,730 --> 00:14:11,200 If I click on next, I will not be able to go through next because I don't have many other products. 218 00:14:11,220 --> 00:14:19,340 I only have 16 products, but I can go back, I can click on previous and it should take me to the next 219 00:14:19,440 --> 00:14:20,850 to the to the previous page. 220 00:14:20,850 --> 00:14:25,950 If it doesn't, then we need to add we need to add brackets here. 221 00:14:26,430 --> 00:14:28,380 So here I need to add brackets. 222 00:14:28,710 --> 00:14:32,670 Let me add here brackets and also here brackets because. 223 00:14:33,630 --> 00:14:37,920 Because here I think this could affect the girls. 224 00:14:37,920 --> 00:14:39,690 So we win. 225 00:14:39,840 --> 00:14:42,750 When we add a number or subtract, we need to add in brackets. 226 00:14:43,260 --> 00:14:44,400 Let me try one more time. 227 00:14:44,400 --> 00:14:48,030 So I'm going to go back and refresh and now it should work. 228 00:14:48,990 --> 00:14:52,860 Now, if I click on Previous, it's going to take me to the previous page. 229 00:14:53,250 --> 00:14:56,580 If I click on Next, it's going to take me to the next page. 230 00:14:56,610 --> 00:15:01,440 So as you can see and you can again control the number of products that you have per page. 231 00:15:01,450 --> 00:15:10,980 For example, here, if I say if I say total records per page, if I say one, if I say only one and 232 00:15:10,980 --> 00:15:15,210 save and refresh, I will get only one product page, product per page. 233 00:15:15,600 --> 00:15:18,750 So as you can see now, I'm going to get only one product per page. 234 00:15:19,170 --> 00:15:21,900 And if I click on next, I'm going to get to the next page. 235 00:15:21,900 --> 00:15:24,990 If I click on next, I'm going to get to the next page. 236 00:15:25,470 --> 00:15:27,480 And here is going to display the page number. 237 00:15:27,490 --> 00:15:31,580 For example, for here, if I click on it, it's going to take me to page number four. 238 00:15:31,590 --> 00:15:35,190 If you click on Next, it's going to take me to page number five. 239 00:15:35,730 --> 00:15:36,810 Number six. 240 00:15:37,560 --> 00:15:38,640 Number seven. 241 00:15:39,360 --> 00:15:40,290 Number eight. 242 00:15:41,420 --> 00:15:42,080 Etc.. 243 00:15:42,800 --> 00:15:46,130 And if I click on one, I'm going to get back to page number one. 244 00:15:46,130 --> 00:15:51,290 And I know I can't go to page number here because obviously there's no page. 245 00:15:51,620 --> 00:15:53,840 There's no page that is number zero. 246 00:15:54,020 --> 00:15:55,040 We start from one. 247 00:15:55,700 --> 00:15:56,780 So this is how it works. 248 00:15:56,780 --> 00:15:59,630 And I'm going to be displaying eight products SPEAR which.