1 00:00:00,780 --> 00:00:01,440 Welcome back. 2 00:00:01,890 --> 00:00:04,330 Now it's time to work on deleting a product. 3 00:00:04,350 --> 00:00:06,810 How would you delete a product if you want to do so? 4 00:00:07,170 --> 00:00:08,580 Well, it's very simple. 5 00:00:08,610 --> 00:00:09,870 Let's start working on it. 6 00:00:10,290 --> 00:00:14,700 So the first thing I'm going to do is that I'm going to create a file that's going to be responsible 7 00:00:14,700 --> 00:00:15,990 for deleting a product. 8 00:00:16,050 --> 00:00:17,160 I'm going to say your new. 9 00:00:18,350 --> 00:00:19,370 You file? 10 00:00:21,870 --> 00:00:22,920 You file. 11 00:00:23,670 --> 00:00:30,210 Then I'm going to say delete underscore products, not BHP. 12 00:00:34,120 --> 00:00:39,250 And then what I'm going to do in this file, the first thing I'm going to do is that I'm going to get 13 00:00:39,250 --> 00:00:40,210 a card from here. 14 00:00:41,850 --> 00:00:43,040 First, I'm going to copy this code. 15 00:00:43,060 --> 00:00:45,610 I'm going to make sure that the user, the admin, is logged in. 16 00:00:47,800 --> 00:00:53,020 And the next thing that I'm going to do is that I'm going to activate the button. 17 00:00:53,890 --> 00:00:55,900 So I'm going to go to the products. 18 00:00:56,710 --> 00:00:58,390 And in the products. 19 00:00:59,020 --> 00:01:05,900 What I want to do is that, remember, we have this button, we have edit and delete. 20 00:01:05,920 --> 00:01:06,940 Let's work on the delete. 21 00:01:07,420 --> 00:01:08,290 On the delete. 22 00:01:08,320 --> 00:01:14,620 What we want to do is that we want to say a trip is equal to delete. 23 00:01:16,180 --> 00:01:25,210 Rather got BHP and then I'm going to say product underscore ID is equal to. 24 00:01:27,200 --> 00:01:30,500 BHP and then Echo. 25 00:01:33,460 --> 00:01:34,180 Product. 26 00:01:36,580 --> 00:01:37,540 Product. 27 00:01:39,650 --> 00:01:40,010 I'd. 28 00:01:43,290 --> 00:01:44,290 And that's it. 29 00:01:44,490 --> 00:01:52,810 Year we have a product I.D. and we can delete that product and the product now in the product, in the 30 00:01:52,810 --> 00:01:56,140 delete product, what we want to do is that we want to say it's. 31 00:01:57,770 --> 00:01:58,790 Is it? 32 00:02:00,580 --> 00:02:05,620 Product 80 get first get product ID. 33 00:02:07,370 --> 00:02:11,360 Project I.D. then. 34 00:02:11,690 --> 00:02:13,510 Then if we have the product ready. 35 00:02:15,600 --> 00:02:19,700 What I'm going to do is that I'm going to delete that product and to delete a product from the database, 36 00:02:19,710 --> 00:02:22,440 we need to get a command. 37 00:02:23,550 --> 00:02:26,340 Let me get a command instead of writing it from scratch. 38 00:02:26,820 --> 00:02:33,210 So here so I'm going to get this command, let me get these lines and then maybe paste them here. 39 00:02:33,990 --> 00:02:34,980 And then I'm going to change up. 40 00:02:35,190 --> 00:02:36,300 I'm going to change a few things. 41 00:02:36,330 --> 00:02:43,020 First, I'm going to say statement is equal to connect, repair and then delete the lead. 42 00:02:44,320 --> 00:02:44,860 From. 43 00:02:46,760 --> 00:02:47,340 From where? 44 00:02:47,360 --> 00:02:47,780 From. 45 00:02:47,780 --> 00:02:50,480 We need to delete from products. 46 00:02:51,470 --> 00:02:53,630 Products where. 47 00:02:55,820 --> 00:03:01,370 Where product I.D. is equal to question mark. 48 00:03:01,780 --> 00:03:09,140 And then we say statement bind, bind by RAM. 49 00:03:11,150 --> 00:03:15,710 And then we bind the I, the product ID, product ID. 50 00:03:19,730 --> 00:03:23,600 And we just excused one and that's it. 51 00:03:23,630 --> 00:03:28,430 We need to remove all of these and we need to get the product ID and do a few things. 52 00:03:28,820 --> 00:03:32,390 The first thing that we need to do is, is that at the top we need to import the session. 53 00:03:32,390 --> 00:03:33,680 I'm going to say session start. 54 00:03:35,060 --> 00:03:37,340 Session start. 55 00:03:38,390 --> 00:03:48,890 The next thing that we need to do is that we need to import the the server connection server. 56 00:03:50,990 --> 00:03:51,710 Connection. 57 00:03:53,560 --> 00:03:59,410 And then we need to get a product I.D. So to get the product I.D., we need to store it in a new variable 58 00:03:59,410 --> 00:03:59,650 here. 59 00:03:59,650 --> 00:04:04,870 I'm going to say product underscore I.D. is equal to get. 60 00:04:07,880 --> 00:04:08,480 Get. 61 00:04:10,770 --> 00:04:15,990 Productivity, product R&D. 62 00:04:16,710 --> 00:04:19,890 And lastly, if everything's fine, we just redirect. 63 00:04:20,700 --> 00:04:24,870 We say here, hey there, and then location. 64 00:04:27,340 --> 00:04:27,940 And then. 65 00:04:29,680 --> 00:04:34,930 Products that BHP and then I'm going to say delete. 66 00:04:38,460 --> 00:04:39,210 Deleted. 67 00:04:40,670 --> 00:04:42,920 Set says for. 68 00:04:45,570 --> 00:04:46,500 Successfully. 69 00:04:48,220 --> 00:04:58,000 And then I'm going to say is equal to product has been deleted successfully. 70 00:05:00,240 --> 00:05:05,310 And you can add if statement to check whether the product has been deleted or not. 71 00:05:05,640 --> 00:05:12,570 You can say here if and then if product has been deleted successfully, you can take the user to this 72 00:05:12,570 --> 00:05:20,970 page and else else you can display the same message, the same the same line. 73 00:05:21,180 --> 00:05:23,940 You can use the same line, but with with a different message. 74 00:05:23,940 --> 00:05:25,830 You can say delete, deleted. 75 00:05:28,670 --> 00:05:29,240 Failure. 76 00:05:29,240 --> 00:05:30,720 Message fail. 77 00:05:30,740 --> 00:05:31,230 Failure. 78 00:05:31,250 --> 00:05:31,970 Just failure. 79 00:05:32,630 --> 00:05:34,520 And then here couldn't defeat the product. 80 00:05:36,610 --> 00:05:38,020 Good night. 81 00:05:40,910 --> 00:05:43,550 The elite product. 82 00:05:43,550 --> 00:05:48,220 And then in the in the in the product speech, we need to display these messages. 83 00:05:48,230 --> 00:05:56,390 So here, remember, we have we have this code, we can copy this code and then we can paste it here 84 00:05:56,390 --> 00:06:02,510 in case of failure, we, we say delete, delete. 85 00:06:03,500 --> 00:06:06,230 The key was I think delete it failure. 86 00:06:07,730 --> 00:06:08,990 Related failure. 87 00:06:12,270 --> 00:06:13,950 And we just say delete it. 88 00:06:13,950 --> 00:06:14,550 Failure. 89 00:06:15,810 --> 00:06:17,010 Delete it. 90 00:06:18,500 --> 00:06:19,190 Failure. 91 00:06:20,840 --> 00:06:23,240 And in case of success, we copy the same message. 92 00:06:23,240 --> 00:06:24,170 And this place here. 93 00:06:26,870 --> 00:06:28,100 And then we see it. 94 00:06:28,100 --> 00:06:30,830 It's this message, and instead of it, it's a message. 95 00:06:31,580 --> 00:06:35,060 The message was deleted, successful, deleted, successful. 96 00:06:35,060 --> 00:06:35,840 So I'm going to copy it. 97 00:06:36,380 --> 00:06:37,430 And then I'm going to sit here. 98 00:06:39,100 --> 00:06:39,940 Deleted. 99 00:06:42,660 --> 00:06:46,560 Successfully and he deleted successfully. 100 00:06:46,590 --> 00:06:47,130 That's it. 101 00:06:47,670 --> 00:06:50,160 Pretty simple and awesome. 102 00:06:50,790 --> 00:06:52,700 Let me now heading over to the browser at this. 103 00:06:52,710 --> 00:06:58,800 Let me let me refresh first and then we have here we should have here all of the products. 104 00:06:59,370 --> 00:07:03,330 Let me delete the last product because I don't want the last product from my system. 105 00:07:04,140 --> 00:07:06,510 So the last product is this one, the green shoots. 106 00:07:06,750 --> 00:07:07,560 Click on delete. 107 00:07:08,540 --> 00:07:14,210 And if you click on delete it, as you can see, it says product has been deleted successfully. 108 00:07:14,540 --> 00:07:15,950 Let's verify this leaning. 109 00:07:15,950 --> 00:07:17,180 Go to the last page. 110 00:07:20,700 --> 00:07:24,930 So as you can see, if I go to the last page, the product has been deleted successfully.