WEBVTT 00:00:07.080 --> 00:00:13.180 Right now that's redefined our function let's call it whatever we load the notes. 00:00:13.320 --> 00:00:13.940 OK. 00:00:14.190 --> 00:00:20.490 So we need to call it the same way we've done with the click on notes function 00:00:25.720 --> 00:00:28.020 on there and 00:00:30.660 --> 00:00:34.220 there as well because we reload the notes. 00:00:34.800 --> 00:00:35.390 OK. 00:00:35.880 --> 00:00:39.270 Now let's save and go to the delete note. 00:00:39.390 --> 00:00:40.680 Those file. 00:00:40.890 --> 00:00:46.380 So first of all we need to get the ID of the notes through Ajax. 00:00:46.440 --> 00:00:48.690 So this creates a variable. 00:00:48.690 --> 00:00:57.680 Notes ID and gets the ID of the notes from the post array. 00:00:58.370 --> 00:00:59.710 OK. 00:01:01.890 --> 00:01:11.280 So the key here is going to be ID because when we wrote our AJAX call in the data 00:01:14.470 --> 00:01:18.120 promiser we sense ID. 00:01:18.630 --> 00:01:20.140 OK. 00:01:20.730 --> 00:01:30.370 Now let's run the query so we can create a glary to the leads in there is using its ID. 00:01:31.050 --> 00:01:43.080 So the syntax is deletes from our table notes and the condition is where ID equals 00:01:46.980 --> 00:01:50.950 the ID of the notes which is notes ID. 00:01:51.120 --> 00:01:58.740 You can add another condition if you want just for extra security you can get the user id from the session 00:01:58.740 --> 00:02:05.000 variable and add another condition in the where statements. 00:02:05.050 --> 00:02:07.170 OK but it is not necessary. 00:02:07.230 --> 00:02:10.470 OK so now let's run the query 00:02:13.770 --> 00:02:18.900 using them as choli and the sql query function 00:02:22.780 --> 00:02:24.800 is going to take couple of promises again. 00:02:25.110 --> 00:02:29.340 The link variable we saw the connection and our query. 00:02:29.770 --> 00:02:35.310 OK so now we get a check if we get any errors. 00:02:35.380 --> 00:02:40.080 Ok so if results is false. 00:02:40.080 --> 00:02:42.090 So you a check the opposite of results 00:02:44.110 --> 00:02:46.620 . 00:02:48.000 --> 00:02:55.310 Basically for a delete query the results variable is going to be either true or false. 00:02:55.560 --> 00:02:56.660 OK. 00:02:56.850 --> 00:03:02.150 So it's not going to be an object as when we using a selects statement. 00:03:02.400 --> 00:03:07.190 So if that's the case we're going to echo error. 00:03:09.130 --> 00:03:16.720 OK so let's save and refresh our page. 00:03:16.860 --> 00:03:21.550 Let's go to the Edie's mode and the least the first notes. 00:03:22.410 --> 00:03:22.950 OK. 00:03:23.280 --> 00:03:31.350 Now let's go to the database and check if you of course only two notes left. 00:03:31.370 --> 00:03:34.220 Perfect's you've got only two notes. 00:03:34.280 --> 00:03:38.640 OK so we've deleted the other notes. 00:03:38.700 --> 00:03:39.050 OK. 00:03:39.060 --> 00:03:40.670 So everything is working. 00:03:41.040 --> 00:03:41.360 All right. 00:03:41.370 --> 00:03:52.070 Now if we click on the done button we would like to hide all the buttons. 00:03:52.240 --> 00:03:52.970 OK. 00:03:53.100 --> 00:03:58.290 And make all the notes take the full with as before. 00:03:58.560 --> 00:03:59.640 OK. 00:03:59.640 --> 00:04:02.990 And also we're going to hide the numbers and then show the Edie's person. 00:04:03.000 --> 00:04:06.620 So let's go ahead and do this. 00:04:07.500 --> 00:04:08.930 All right. 00:04:09.780 --> 00:04:10.440 So 00:04:13.870 --> 00:04:16.700 let's go Bucks our javascript file. 00:04:17.520 --> 00:04:21.230 OK. 00:04:24.590 --> 00:04:25.380 OK. 00:04:25.920 --> 00:04:28.190 That's where we are. 00:04:29.150 --> 00:04:32.700 So are you going to select the button done. 00:04:33.500 --> 00:04:34.380 OK. 00:04:34.500 --> 00:04:35.040 Using 00:04:37.860 --> 00:04:38.850 its ID 00:04:43.750 --> 00:04:48.400 which is done and then you're going to use the click method 00:04:51.520 --> 00:04:57.300 and the functions who executes it is going to be following. 00:04:59.170 --> 00:05:03.260 So first of all we got to switch to the non Eddie's mode. 00:05:03.280 --> 00:05:03.950 OK. 00:05:04.420 --> 00:05:06.360 So right here we are in the Aries mode. 00:05:06.370 --> 00:05:09.510 If you click on done you go out of touch Eddie's mode. 00:05:09.520 --> 00:05:12.540 So it is mode is going to go back to false. 00:05:13.360 --> 00:05:14.240 OK. 00:05:14.480 --> 00:05:19.460 They come in the switch to Gettysburg. 00:05:20.050 --> 00:05:20.740 All right. 00:05:20.740 --> 00:05:29.440 Next we're going to expand our notes and basically to reduce the weight of the notes we gave them an 00:05:29.440 --> 00:05:30.880 extra class. 00:05:30.880 --> 00:05:33.770 So all we need to do now is remove that class. 00:05:33.940 --> 00:05:34.510 OK. 00:05:34.930 --> 00:05:35.230 So 00:05:38.740 --> 00:05:47.390 we're going to select all notes using the class notes header. 00:05:48.480 --> 00:05:49.530 OK. 00:05:50.320 --> 00:06:00.130 And instead of adding the class we're going to remove the class to a class we've added was a couple 00:06:00.130 --> 00:06:01.090 of classes. 00:06:01.090 --> 00:06:09.850 Call them x x 7 for x y small devices and call them Hassam 9. 00:06:10.150 --> 00:06:13.340 OK. 00:06:13.630 --> 00:06:18.880 And then we're going to show certain elements and hide certain elements. 00:06:18.930 --> 00:06:23.640 OK so show height elements. 00:06:23.870 --> 00:06:24.990 So these are the common. 00:06:24.990 --> 00:06:25.390 They're 00:06:28.180 --> 00:06:30.250 expanding those. 00:06:31.480 --> 00:06:33.850 OK. 00:06:36.140 --> 00:06:37.950 OK. 00:06:39.280 --> 00:06:44.550 So let's use the show height function. 00:06:48.580 --> 00:06:53.120 So we are going to show the edits button. 00:06:53.750 --> 00:06:55.760 OK. 00:06:57.030 --> 00:06:58.520 Use its ID. 00:06:59.380 --> 00:07:07.530 And we're going to hide the done button so we can do this using the keyword this because we are inside 00:07:07.700 --> 00:07:09.850 the elements which we are selecting. 00:07:10.120 --> 00:07:17.110 And also we are going to hide the police presence so we can do that using the Dili's class. 00:07:18.640 --> 00:07:19.330 OK. 00:07:19.630 --> 00:07:31.250 So let's save and refresh as click on edits click on done again. 00:07:31.970 --> 00:07:34.280 Perfect's everything is working. 00:07:34.630 --> 00:07:36.150 All right. 00:07:36.220 --> 00:07:36.460 All right. 00:07:36.460 --> 00:07:40.270 Now let's play little bits with our up and make sure everything is working. 00:07:40.270 --> 00:07:42.550 So if I click on odd note 00:07:48.410 --> 00:07:58.140 and click on all notes perfect edits deletes done. 00:07:59.020 --> 00:08:00.170 OK so now what. 00:08:00.180 --> 00:08:06.290 Dave click on note straight away from here. 00:08:07.510 --> 00:08:07.990 OK. 00:08:08.080 --> 00:08:09.850 All works. 00:08:10.150 --> 00:08:15.100 Now if I go back you all know it's great. 00:08:15.200 --> 00:08:23.890 It's deletes done edits deletes done 00:08:27.160 --> 00:08:31.470 so you don't have any notes at the moment so it is click on notes. 00:08:31.840 --> 00:08:37.420 If I go back to all notes without writing anything that I would expect a message saying you have not 00:08:37.420 --> 00:08:38.680 created a note yet. 00:08:38.890 --> 00:08:39.700 OK. 00:08:40.420 --> 00:08:50.500 So if I click Edit now and done nothing happens other notes it's other one. 00:08:52.050 --> 00:08:52.290 OK 00:08:55.600 --> 00:08:58.440 another one. 00:08:59.710 --> 00:09:00.270 OK. 00:09:00.280 --> 00:09:02.860 Everything seems to be working. 00:09:02.860 --> 00:09:06.350 You might want to add one improvements to the code. 00:09:06.370 --> 00:09:15.140 So basically if you delete all notes OK like this then you might want to show a message in here. 00:09:15.340 --> 00:09:16.930 OK when you click on done 00:09:19.750 --> 00:09:21.780 just like this one for example. 00:09:21.940 --> 00:09:24.950 OK that's something you can add to the code. 00:09:25.200 --> 00:09:32.920 But for now we're going to leave it's like this. 00:09:32.920 --> 00:09:35.380 All right. 00:09:35.380 --> 00:09:35.680 All right. 00:09:35.680 --> 00:09:41.770 Now before we move to the profile management I'm just going to make a quick change to this section. 00:09:41.770 --> 00:09:45.860 Basically we need to show the user name of our user. 00:09:46.000 --> 00:09:47.000 OK. 00:09:47.500 --> 00:09:51.610 Just like we call they're locked in us whatever the user name is. 00:09:51.640 --> 00:10:04.000 So we're going to go back to our APHC file main page looked in those BHP and we're going to go to this 00:10:04.000 --> 00:10:05.130 link. 00:10:05.170 --> 00:10:14.920 So instead of using a name we can write some code in there to retrieve the actual user name of our user 00:10:14.940 --> 00:10:15.690 . 00:10:16.420 --> 00:10:19.600 OK. 00:10:19.600 --> 00:10:21.890 So we can get the user name from the session array. 00:10:22.030 --> 00:10:26.920 So he's going to echo session. 00:10:28.330 --> 00:10:32.680 And the key is going to be using any. 00:10:33.740 --> 00:10:34.910 OK. 00:10:35.840 --> 00:10:45.250 So I save the reason why we can access does is because when we look at our user in we stored this inside 00:10:45.340 --> 00:10:46.550 the session array. 00:10:46.570 --> 00:10:51.600 OK so let's refresh our page. 00:10:52.680 --> 00:10:53.270 OK. 00:10:53.290 --> 00:11:02.550 And we can see the user name and that's the Royse username for user id 11. 00:11:03.600 --> 00:11:06.920 It's OK. 00:11:07.270 --> 00:11:13.330 All right so in the next video we're going to start writing code for profil management. 00:11:13.530 --> 00:11:19.070 OK.