PHP-and-MySQL/C3/MySQL-Part-8/English-timed

From Script | Spoken-Tutorial
Revision as of 18:03, 2 January 2013 by Minal (Talk | contribs)

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

Contributors and Content Editors

Gaurav, Minal, PoojaMoolya, Sandhya.np14, Sneha