Difference between revisions of "PHP-and-MySQL/C3/MySQL-Part-7/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with '{| border=1 !Time !Narration |- |0:00 |In this part of the tutorial, I am going to give you a chance to create a simple program. |- |0:06 |This program will allow us to select a…')
 
Line 3: Line 3:
 
!Narration
 
!Narration
 
|-
 
|-
|0:00
+
|00:01
 
|In this part of the tutorial, I am going to give you a chance to create a simple program.  
 
|In this part of the tutorial, I am going to give you a chance to create a simple program.  
 
|-
 
|-
|0:06
+
|00:08
 
|This program will allow us to select a name from a list.
 
|This program will allow us to select a name from a list.
 
|-
 
|-
|0:15
+
|00:15
 
|Also it will allow us to update a piece of information and I am selecting the ability to update the name itself.
 
|Also it will allow us to update a piece of information and I am selecting the ability to update the name itself.
 
|-
 
|-
|0:25
+
|00:25
 
|I will say the "firstname" in this for example.   
 
|I will say the "firstname" in this for example.   
 
|-
 
|-
|0:28
+
|00:28
 
|Here, we can select from a list and then update that information.
 
|Here, we can select from a list and then update that information.
 
|-
 
|-
|0:33
+
|00:33
 
|I will modify this page a little bit to get rid of some information which we do not need.
 
|I will modify this page a little bit to get rid of some information which we do not need.
 
|-  
 
|-  
|0:38
+
|00:39
 
|We don't need this echoing here.
 
|We don't need this echoing here.
 
|-
 
|-
|0:40
+
|00:41
 
|We are also going to change our form here, so we don't need this for now.
 
|We are also going to change our form here, so we don't need this for now.
 
|-
 
|-
|0:47
+
|00 :47
 
|Let us delete that.
 
|Let us delete that.
 
|-
 
|-
|0:48
+
|00:49
 
|We are not going to  need this either.  
 
|We are not going to  need this either.  
 
|-
 
|-
|0:52
+
|00:52
 
|We will only need the firstname and lastname. Date of birth and gender don't really matter.
 
|We will only need the firstname and lastname. Date of birth and gender don't really matter.
 
|-
 
|-
|0:59
+
|00:59
 
|Let us delete this too.We don't need this either.... neither this.
 
|Let us delete this too.We don't need this either.... neither this.
 
|-
 
|-
|1:04
+
|01:04
 
|Ok there we are.
 
|Ok there we are.
 
|-
 
|-
|1:05
+
|01:06
 
|This tutorial is not going to be exhaustive and is not going to be completely correct either.  
 
|This tutorial is not going to be exhaustive and is not going to be completely correct either.  
 
|-
 
|-
|1:14
+
|01:13
 
|However it is going to show you how to apply your records to html select boxes.  
 
|However it is going to show you how to apply your records to html select boxes.  
 
|-
 
|-
|1:22
+
|01:23
 
|And also showing  you how to update information based on what you selected.
 
|And also showing  you how to update information based on what you selected.
 
|-
 
|-
|1:31
+
|01:30
 
|As you see here, I am going to create some data inside the '''while loop'''.  
 
|As you see here, I am going to create some data inside the '''while loop'''.  
 
|-
 
|-
|1:45
+
|01:45
 
|We are going to create some html data here.
 
|We are going to create some html data here.
 
|-
 
|-
Line 60: Line 60:
 
|Here I am echoing out. Let me just stop here for the time being.
 
|Here I am echoing out. Let me just stop here for the time being.
 
|-
 
|-
|1:55
+
|01:56
 
|Lets go down here.
 
|Lets go down here.
 
|-
 
|-
|1:57
+
|01:58
 
|We are going to create a select area which is a select box.  
 
|We are going to create a select area which is a select box.  
 
|-
 
|-
|2:01
+
|02:02
 
|It is a drop down box and for each of these boxes, we have an option.
 
|It is a drop down box and for each of these boxes, we have an option.
 
|-
 
|-
|2:14
+
|02:14
 
|For example this could be 1 or 2.
 
|For example this could be 1 or 2.
 
|-
 
|-
|2:15
+
|02:17
 
|So lets come back here and  "refresh button". Lets refresh this.  
 
|So lets come back here and  "refresh button". Lets refresh this.  
 
|-
 
|-
|2:27
+
|02:28
 
|Let us get rid of this dialogue box.
 
|Let us get rid of this dialogue box.
 
|-
 
|-
|2:30
+
|02:31
|Here we have got 1 or 2. This is the piece of html here.
+
|Here we got 1 or 2. This is the piece of html here.
 
|-
 
|-
|2:35
+
|02:36
 
|Here we are going to apply this and we are going to search for our records. We are going to give a name.......... in each of these option boxes.
 
|Here we are going to apply this and we are going to search for our records. We are going to give a name.......... in each of these option boxes.
 
|-
 
|-
|2:40
+
|02:44
 
|I will give an option name to each record that we found.
 
|I will give an option name to each record that we found.
 
|-
 
|-
|2:43
+
|02:48
 
|If you don't understand this, it means inside the code which is going to be repeated for every record, outside the loop, over here, we want to echo the first part of our html code.
 
|If you don't understand this, it means inside the code which is going to be repeated for every record, outside the loop, over here, we want to echo the first part of our html code.
 
|-
 
|-
|3:00
+
|03:00
 
|This will be "select" and the name of that is going to be "name".
 
|This will be "select" and the name of that is going to be "name".
 
|-  
 
|-  
|3:08
+
|03:08
 
|Or rather let me call it '''people name'''.
 
|Or rather let me call it '''people name'''.
 
|-
 
|-
|3:13
+
|03:13
 
|After this, outside of our while  loop, here we are going to echo out the ends tag. So  let us type  forward slash and select".
 
|After this, outside of our while  loop, here we are going to echo out the ends tag. So  let us type  forward slash and select".
 
|-
 
|-
|3:21
+
|03:24
 
|The reason for not incorporating this inside our while loop is because if it is repeating, then it is going to repeat the start and the end tags and not the option part, which we need.
 
|The reason for not incorporating this inside our while loop is because if it is repeating, then it is going to repeat the start and the end tags and not the option part, which we need.
 
|-
 
|-
|3:36
+
|03:36
 
|Here the option part goes inside the loop.
 
|Here the option part goes inside the loop.
 
|-
 
|-
|3:39
+
|03:39
 
|Let me echo out, lets say the "firstname".  
 
|Let me echo out, lets say the "firstname".  
 
|-
 
|-
|3:41
+
|03:42
 
|And what this does is, for every record, it is going to echo this option code
 
|And what this does is, for every record, it is going to echo this option code
 
|-
 
|-
|3:48
+
|03:48
 
|And if you remember down here, we had "option" and "option end".  
 
|And if you remember down here, we had "option" and "option end".  
 
|-
 
|-
 
|3:52
 
|3:52
|This was being  repeated over and over again.  
+
|This is being  repeated over and over again.  
 
|-
 
|-
|3:56
+
|03:57
 
|Now we have the "select" part here and the "select end" here.
 
|Now we have the "select" part here and the "select end" here.
 
|-
 
|-
|3:58
+
|04:01
 
|We need this echoed once, this echoed once and these echoed for every record in the database or in the table.
 
|We need this echoed once, this echoed once and these echoed for every record in the database or in the table.
 
|-
 
|-
|4:10
+
|04:10
 
|You can verify this by refreshing.  
 
|You can verify this by refreshing.  
 
|-
 
|-
|4:12
+
|04:13
 
|Oh! Where's our code gone?
 
|Oh! Where's our code gone?
 
|-
 
|-
|4:14
+
|04:15
|Looks go back and find where the mistake is.  Actually we need to change this part here - the "if" statement.
+
|Lets    go back and find where the mistake is.  Actually we need to change this part here - the "if" statement.
 
|-
 
|-
|4:25
+
|04:25
 
|We are not looking for our "submit" button anymore, so we can delete that.
 
|We are not looking for our "submit" button anymore, so we can delete that.
 
|-
 
|-
|4:28
+
|04:29
 
|So now, presuming everything is alright, we will refresh and we have a list box of all the first names of the records in our database.
 
|So now, presuming everything is alright, we will refresh and we have a list box of all the first names of the records in our database.
 
|-
 
|-
|4:39
+
|04:39
 
|Now I want to make this look better and so I will say "surname" or "lastname" in the code.
 
|Now I want to make this look better and so I will say "surname" or "lastname" in the code.
 
|-
 
|-
|4:46
+
|04:47
 
|There you go!  Refresh.  This is a really easy way to use html code, is'nt it?
 
|There you go!  Refresh.  This is a really easy way to use html code, is'nt it?
 
|-
 
|-
|4:52
+
|04:52
 
|Now we are going to talk about "option".
 
|Now we are going to talk about "option".
 
|-
 
|-
|4:52
+
|04:56
 
|We need to have a name for each option and the name for each one will be "id".
 
|We need to have a name for each option and the name for each one will be "id".
 
|-
 
|-
|5:00
+
|05:00
|If I click on refresh and come on to my page source, you can see that we got 1,2,3,4, in each one here.
+
|If I click on refresh and come on my page source, you can see that we got 1,2,3,4, in each one here.
 
|-
 
|-
|5:13
+
|05:13
 
|This is really useful because now we can update, unique records rather than just going by the name.
 
|This is really useful because now we can update, unique records rather than just going by the name.
 
|-
 
|-
|5:23
+
|05:23
 
|So  here, I will start to create my update form.
 
|So  here, I will start to create my update form.
 
|-
 
|-
|5:27
+
|05:28
 
|I will put an input box after my "select", and this is going to be "text".  
 
|I will put an input box after my "select", and this is going to be "text".  
 
|-
 
|-
|5:33
+
|05:33
 
|The name will be '''to change'''. This is what we are going to change by.
 
|The name will be '''to change'''. This is what we are going to change by.
 
|-
 
|-
| 5:40
+
| 05:40
 
|Next we will create another button or another input element called the '''submit''' button whose value will  be "change".
 
|Next we will create another button or another input element called the '''submit''' button whose value will  be "change".
 
|-
 
|-
|5:53
+
|05:53
 
|Here I will just change the first name for now. Just for an example.
 
|Here I will just change the first name for now. Just for an example.
 
|-
 
|-
|5:58
+
|05:58
 
|So here is the basis of our form.
 
|So here is the basis of our form.
 
|-
 
|-
|6:00
+
|06:00
 
|We have got the "name" here and what we want to change it to.  
 
|We have got the "name" here and what we want to change it to.  
 
|-
 
|-
Line 180: Line 180:
 
|So here I will change it from "Alex" to "Alexander" and then click on '''Change'''.
 
|So here I will change it from "Alex" to "Alexander" and then click on '''Change'''.
 
|-
 
|-
|6:10
+
|06:10
 
|At the moment nothing is happening.
 
|At the moment nothing is happening.
 
|-
 
|-
|6:12
+
|06:12
 
|Now what we need to do is put this inside the form so that I can end my form.
 
|Now what we need to do is put this inside the form so that I can end my form.
 
|-
 
|-
|6:18
+
|06:17
 
|Over here, it is getting kind of messy but hopefully you can see whats going on.  
 
|Over here, it is getting kind of messy but hopefully you can see whats going on.  
 
|-
 
|-
|6:23
+
|06:23
 
|Let me scroll down over here.  Up here we need to start our form.
 
|Let me scroll down over here.  Up here we need to start our form.
 
|-
 
|-
|6:22
+
|06:27
 
|The action will be the page we are on at the moment which is "mysql dot php".
 
|The action will be the page we are on at the moment which is "mysql dot php".
 
|-
 
|-
|6:33
+
|06:33
 
|Infact I will do it on another page.  
 
|Infact I will do it on another page.  
 
|-
 
|-
|6:36
+
|06:36
 
|So rename it to "mysql update dot php".
 
|So rename it to "mysql update dot php".
 
|-
 
|-
|6:40
+
|06:40
 
|This will make it a bit easier for you to see and a lot easier for me to write.
 
|This will make it a bit easier for you to see and a lot easier for me to write.
 
|-
 
|-
|6:45
+
|06:45
 
|Then by refreshing that, we can see that we go to the new page which isn't found at the moment.
 
|Then by refreshing that, we can see that we go to the new page which isn't found at the moment.
 
|-
 
|-
|6:52
+
|06:52
 
|I am going to create that inside here.
 
|I am going to create that inside here.
 
|-
 
|-
|6:55
+
|06:55
 
|We will save that straight away as "mysql underscore update dot php".
 
|We will save that straight away as "mysql underscore update dot php".
 
|-
 
|-
|7:00
+
|07:00
 
|We need to start our php tags.
 
|We need to start our php tags.
 
|-
 
|-
|7:02
+
|07:03
 
|We need to require our "connect dot php" because we are connecting to our database again.
 
|We need to require our "connect dot php" because we are connecting to our database again.
 
|-
 
|-
|7:14
+
|07:14
 
|We also need to get our value of the name that we are changing.
 
|We also need to get our value of the name that we are changing.
 
|-
 
|-
|7:17
+
|07:18
 
|So we will call our select name '''peoplename'''.  
 
|So we will call our select name '''peoplename'''.  
 
|-
 
|-
|7:20
+
|07:20
 
|So here we will type "peoplename" equals POST and  '''peoplename'''.
 
|So here we will type "peoplename" equals POST and  '''peoplename'''.
 
|-
 
|-
|7:28
+
|07:29
 
|That is the name of the html element we are taking.
 
|That is the name of the html element we are taking.
 
|-
 
|-
|7:32
+
|07:33
 
|This is going to be called 1,2,3.
 
|This is going to be called 1,2,3.
 
|-
 
|-
|7:36
+
|07:37
 
|This is our id which is inside our database.  
 
|This is our id which is inside our database.  
 
|-
 
|-
|7:39
+
|07:39
 
|"tochange" is the field in which we have ready to type our new value in.
 
|"tochange" is the field in which we have ready to type our new value in.
 
|-
 
|-
|7:46
+
|07:47
 
|Here I will code a brief '''if statement''' just to say if '''peoplename''' and '''tochange'''.
 
|Here I will code a brief '''if statement''' just to say if '''peoplename''' and '''tochange'''.
 
|-
 
|-
|7:57
+
|07:56
 
|This makes sure that we have got both our values there.
 
|This makes sure that we have got both our values there.
 
|-  
 
|-  
|8:00
+
|08:01
 
|Then what we will do is type "change" equals "mysql query" and that is simply "UPDATE people", which is the name of our table here.
 
|Then what we will do is type "change" equals "mysql query" and that is simply "UPDATE people", which is the name of our table here.
 
|-
 
|-
|8:17
+
|08:17
 
|"UPDATE people SET firstname equals tochange" where "firstname equals"....
 
|"UPDATE people SET firstname equals tochange" where "firstname equals"....
 
|-
 
|-
|8:30
+
|08:31
 
|No, in fact we are not..... We are changing it by "id", isn't it?
 
|No, in fact we are not..... We are changing it by "id", isn't it?
 
|-
 
|-
|8:39
+
|08:39
|So we type where the "ID" is equal to the value of this "peoplename".
+
|So we type where the "ID" is equal to the value of the"peoplename".
 
|-
 
|-
|8:52
+
|08:52
 
|Right, lets go back.   
 
|Right, lets go back.   
 
|-
 
|-
|8:57
+
|08:58
 
|Lets say I picked "Kyle" to change the name of "Kyle".
 
|Lets say I picked "Kyle" to change the name of "Kyle".
 
|-
 
|-
|9:02
+
|09:02
 
|The name of this is 2 so the "peoplename" is also 2.  
 
|The name of this is 2 so the "peoplename" is also 2.  
 
|-
 
|-
|9:05
+
|09:06
 
|So we are changing this to this where the id is this.
 
|So we are changing this to this where the id is this.
 
|-
 
|-
|9:10
+
|09:11
 
|I will show you that in the next part of tutorial because I am running out of time.
 
|I will show you that in the next part of tutorial because I am running out of time.
 
|-
 
|-
|9:14
+
|09:15
 
|So I will see you there soon.  This is Evan Varkey dubbing for the Spoken Tutorial Project. (Script contributed by Juanita Jayakar).
 
|So I will see you there soon.  This is Evan Varkey dubbing for the Spoken Tutorial Project. (Script contributed by Juanita Jayakar).

Revision as of 16:28, 12 July 2013

Time Narration
00:01 In this part of the tutorial, I am going to give you a chance to create a simple program.
00:08 This program will allow us to select a name from a list.
00:15 Also it will allow us to update a piece of information and I am selecting the ability to update the name itself.
00:25 I will say the "firstname" in this for example.
00:28 Here, we can select from a list and then update that information.
00:33 I will modify this page a little bit to get rid of some information which we do not need.
00:39 We don't need this echoing here.
00:41 We are also going to change our form here, so we don't need this for now.
00 :47 Let us delete that.
00:49 We are not going to need this either.
00:52 We will only need the firstname and lastname. Date of birth and gender don't really matter.
00:59 Let us delete this too.We don't need this either.... neither this.
01:04 Ok there we are.
01:06 This tutorial is not going to be exhaustive and is not going to be completely correct either.
01:13 However it is going to show you how to apply your records to html select boxes.
01:23 And also showing you how to update information based on what you selected.
01:30 As you see here, I am going to create some data inside the while loop.
01:45 We are going to create some html data here.
1:47 Here I am echoing out. Let me just stop here for the time being.
01:56 Lets go down here.
01:58 We are going to create a select area which is a select box.
02:02 It is a drop down box and for each of these boxes, we have an option.
02:14 For example this could be 1 or 2.
02:17 So lets come back here and "refresh button". Lets refresh this.
02:28 Let us get rid of this dialogue box.
02:31 Here we got 1 or 2. This is the piece of html here.
02:36 Here we are going to apply this and we are going to search for our records. We are going to give a name.......... in each of these option boxes.
02:44 I will give an option name to each record that we found.
02:48 If you don't understand this, it means inside the code which is going to be repeated for every record, outside the loop, over here, we want to echo the first part of our html code.
03:00 This will be "select" and the name of that is going to be "name".
03:08 Or rather let me call it people name.
03:13 After this, outside of our while loop, here we are going to echo out the ends tag. So let us type forward slash and select".
03:24 The reason for not incorporating this inside our while loop is because if it is repeating, then it is going to repeat the start and the end tags and not the option part, which we need.
03:36 Here the option part goes inside the loop.
03:39 Let me echo out, lets say the "firstname".
03:42 And what this does is, for every record, it is going to echo this option code
03:48 And if you remember down here, we had "option" and "option end".
3:52 This is being repeated over and over again.
03:57 Now we have the "select" part here and the "select end" here.
04:01 We need this echoed once, this echoed once and these echoed for every record in the database or in the table.
04:10 You can verify this by refreshing.
04:13 Oh! Where's our code gone?
04:15 Lets go back and find where the mistake is. Actually we need to change this part here - the "if" statement.
04:25 We are not looking for our "submit" button anymore, so we can delete that.
04:29 So now, presuming everything is alright, we will refresh and we have a list box of all the first names of the records in our database.
04:39 Now I want to make this look better and so I will say "surname" or "lastname" in the code.
04:47 There you go! Refresh. This is a really easy way to use html code, is'nt it?
04:52 Now we are going to talk about "option".
04:56 We need to have a name for each option and the name for each one will be "id".
05:00 If I click on refresh and come on my page source, you can see that we got 1,2,3,4, in each one here.
05:13 This is really useful because now we can update, unique records rather than just going by the name.
05:23 So here, I will start to create my update form.
05:28 I will put an input box after my "select", and this is going to be "text".
05:33 The name will be to change. This is what we are going to change by.
05:40 Next we will create another button or another input element called the submit button whose value will be "change".
05:53 Here I will just change the first name for now. Just for an example.
05:58 So here is the basis of our form.
06:00 We have got the "name" here and what we want to change it to.
6:04 So here I will change it from "Alex" to "Alexander" and then click on Change.
06:10 At the moment nothing is happening.
06:12 Now what we need to do is put this inside the form so that I can end my form.
06:17 Over here, it is getting kind of messy but hopefully you can see whats going on.
06:23 Let me scroll down over here. Up here we need to start our form.
06:27 The action will be the page we are on at the moment which is "mysql dot php".
06:33 Infact I will do it on another page.
06:36 So rename it to "mysql update dot php".
06:40 This will make it a bit easier for you to see and a lot easier for me to write.
06:45 Then by refreshing that, we can see that we go to the new page which isn't found at the moment.
06:52 I am going to create that inside here.
06:55 We will save that straight away as "mysql underscore update dot php".
07:00 We need to start our php tags.
07:03 We need to require our "connect dot php" because we are connecting to our database again.
07:14 We also need to get our value of the name that we are changing.
07:18 So we will call our select name peoplename.
07:20 So here we will type "peoplename" equals POST and peoplename.
07:29 That is the name of the html element we are taking.
07:33 This is going to be called 1,2,3.
07:37 This is our id which is inside our database.
07:39 "tochange" is the field in which we have ready to type our new value in.
07:47 Here I will code a brief if statement just to say if peoplename and tochange.
07:56 This makes sure that we have got both our values there.
08:01 Then what we will do is type "change" equals "mysql query" and that is simply "UPDATE people", which is the name of our table here.
08:17 "UPDATE people SET firstname equals tochange" where "firstname equals"....
08:31 No, in fact we are not..... We are changing it by "id", isn't it?
08:39 So we type where the "ID" is equal to the value of the"peoplename".
08:52 Right, lets go back.
08:58 Lets say I picked "Kyle" to change the name of "Kyle".
09:02 The name of this is 2 so the "peoplename" is also 2.
09:06 So we are changing this to this where the id is this.
09:11 I will show you that in the next part of tutorial because I am running out of time.
09:15 So I will see you there soon. 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