Difference between revisions of "PHP-and-MySQL/C3/MySQL-Part-8/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) |
|||
Line 3: | Line 3: | ||
!Narration | !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. | |Welcome back! In our previous tutorial, we have established what we are going to change and how we are going to change it. | ||
|- | |- |
Revision as of 12:17, 1 September 2014
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:09 | We did go through that. |
00:11 | So, now I will test my code. |
00:13 | If we look at our database, we have a few records here. |
00:17 | 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:29 | Here I will use Kyle's record as an example and change it to a particular value. |
00:34 | 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:46 | 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:58 | I think I made a mistake. My mistake was that it was "name" before and now I will change this to "value". |
01:06 | 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:25 | 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:37 | 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 has shown visible changes. |
01:47 | But when we click on "Browse" and scroll down, we can see that "Kyle" has now been replaced by "Karen". |
01:54 | 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 if 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:34 | To show you how to Delete, I will close this page and and remove this box and edit this. |
02:46 | 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:01 | Let us now not resend that and let us go back to "mysql.php". |
03:08 | 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:24 | But it has not been deleted at the moment. |
03:27 | Let us make sure all our records are intact first. |
03:31 | As you can see here, we have all our records intact and I will choose to delete a particular record. |
03:37 | Let us say delete "Emily Headen", so I will choose the record of Emily Headen to be deleted. |
03:45 | Now we need to submit this to a new page called "mysql underscore delete.php". |
03:52 | For this, we are going to create a new page save as mysql underscore delete.php |
03:59 | We will do exactly the same as we had done before. |
0 4:03 | 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:47 | Here we can see that we have our name values and our id value here for each case of each record. |
04:54 | 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:14 | Now I am going to echo out to give you an example of how it is processed. |
05:20 | 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:52 | Let us type "people" and "WHERE id equals "todelete". |
05:57 | The "todelete" variable which is the id of the person that we selected from this list. |
06:03 | 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:17 | When I click on "Emily Headen" and click on "Delete", nothing has happened. |
06:22 | 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. |
6:50 | 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). |