PHP-and-MySQL/C3/MySQL-Part-8/English
From Script | Spoken-Tutorial
Revision as of 11:58, 10 July 2014 by Pratik kamble (Talk | contribs)
Time | Narration |
00:00 | Welcome back! In our previous tutorial, we have established what we are going to change and how we are going to change it. |
00:08 | We did go through that. |
00:10 | So, now I will test my code. |
00:12 | If we look at our database, we have a few records here. |
00:18 | I am going to delete David's record here because it was from another tutorial. |
00:23 | After the deletion, we have the records of Alex, Kyle, Emily and Dale |
00:28 | Here I will use Kyle's record as an example and change it to a particular value. |
00:33 | We will refresh our page and make sure it is updated. |
00:38 | I will select "Kyle" and I will change this to "Karen" and I will click on "Change" and here everything has disappeared. |
00:45 | Now we will come back into our table and click on "Browse" to refresh it. |
00:50 | we will scroll down and find that nothing has changed. |
00:57 | I think I made a mistake. My mistake was that it was "name" before and now I will change this to "value". |
01:05 | This needs to be set to "value" instead of "name" |
01:09 | "value" holds the value... of anything here that has been selected; so the value is "id". |
01:15 | When we submit our form, it will come through and the value will be contained within here in "id". |
01:24 | So, I found and fixed the problem and now I will go back and refresh. |
01:30 | Here I will once again change "Kyle" to "Karen". By clicking on "Change" you can see that nothing has happened. |
01:36 | Even when I enter my database, we can see that we have got Alex, Kyle, Emily and Dale. |
01:42 | Since we had changed "Kyle" to "Karen", our id should have shown the changes. |
01:47 | But when we click on "Browse" and scroll down, we can see that "Kyle" has now been replaced by "Karen". |
01:53 | Hence, you can also update values using forms. |
01:57 | It is very easy, as long as you have a standard knowledge of
|
02:15 | You will be able to learn all this, as long as you learn the basic set of these tutorials. |
02:20 | As of now, in this tutorial, you have learnt inserting and updating and so on so forth. |
02:28 | The last thing I will show you is how to delete. |
02:33 | To show you how to Delete, I will close this page and and remove this box and edit this. |
02:45 | I will replace "Change" with "Delete". |
02:49 | Here I will be deleting records where we have a particular name shown. |
02:55 | To do this, I will add "lastname" over here. |
03:00 | Let us not resend that and let us go back to "mysql.php". |
03:07 | Here we now have "Alex Garrett", "Karen Headen" which has been changed or modified from my last example. |
03:17 | We will click "Karen Headen" and we will click on "Delete". This will delete the record. |
03:23 | But it has not been deleted at the moment. |
03:26 | Let us make sure all our records are intact first. |
03:30 | As you can see here, we have all our records intact and I will choose to delete a particular record. |
03:38 | Let us say delete "Emily Headen", so I will choose the record of Emily Headen to be deleted. |
03:44 | Now we need to submit this to a new page called "mysql underscore delete.php". |
03:51 | For this, we are going to create a new page save as mysql underscore delete.php |
03:58 | We will do exactly the same as we had done before. |
04:02 | We are going to "require" our connect so we need to connect to the database. |
04:10 | Oh Sorry! Let us get that back to "require connect.php" and we will again take the variables in. |
04:22 | So let us type "todelete" here and that is "equal to" again a "POST" variable here. |
04:29 | We are posting this form to this page and let us change some values over here. |
04:34 | Let us say "todelete". |
04:37 | So we have changed our "select name" to "todelete". |
04:41 | Now, if you have a look back on this form here, I will show you the code again. |
04:46 | Here we can see that we have our name values and our id value here for each case of each record. |
04:53 | If we refresh, the name of our form is "todelete" and we are taking that into account for each value. |
05:01 | If Emily's record has been selected we will delete the record where the id is equal to 3. |
05:08 | Let us go back to our code and here we have our POST variable. |
05:13 | Now I am going to echo out to give you an example of how it is processed. |
05:19 | We have Emily Headen here. We have 3 there which means that we can use this to delete the id 3 in the database or rather the table. |
05:30 | Here, again we will create a new variable and I will call it "mysql underscore query". |
05:41 | Inside here we will use a whole new set of commands. |
05:45 | We will type in "DELETE FROM" and obviously we will specify our table. |
05:51 | Let us type "people" and "WHERE id equals "todelete". |
05:56 | The "todelete" variable which is the id of the person that we selected from this list. |
06:02 | Now let us test this. Let us say Emily Headen. |
06:08 | Let us check in our database if Emily Headen's record still exists. |
06:13 | Let us refresh to see if the record still exists. |
06:18 | When I click on "Emily Headen" and click on "Delete", nothing has happened. |
06:21 | We have not echoed out but when we click on "Browse" to refresh, we can see that Emily's record has been deleted from the database. |
06:30 | So in this set of tutorials, I have shown you a basic serve command like
|
06:43 | If I have forgotten anything, please let me know and I will add it as parts of these tutorials. |
06:49 | Make sure you subscribe for updates from my channel. |
06:53 | I hope you enjoyed these tutorials. Thanks for watching. |
06:55 | This is Evan Varkey dubbing for the Spoken Tutorial Project. (Script contributed by Juanita Jayakar). |