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

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{| border=1
 
{| border=1
!Time
+
|'''Time'''
!Narration
+
|'''Narration'''
 
|-
 
|-
 
|00:01
 
|00:01
Line 7: Line 7:
 
|-
 
|-
 
|00:03  
 
|00:03  
|This is a pure My SQL php tutorial.
+
|This is a pure '''MySQL php''' tutorial.
 
|-
 
|-
 
|00:06
 
|00:06
Line 13: Line 13:
 
|-  
 
|-  
 
|00:12
 
|00:12
|So that will cover some SQL code and some SQL queries.
+
|So, that will cover some '''SQL code''' and some '''SQL queries'''.
 
|-
 
|-
 
|00:17
 
|00:17
|Ok! Lets start.
+
|Ok! Let's start.
 
|-
 
|-
 
|00:19
 
|00:19
|Here I am going to show the directory structure of "mysql"
+
|Here I am going to show the '''directory''' structure of "MySQL"
 
|-
 
|-
 
|00:23
 
|00:23
Line 28: Line 28:
 
|-
 
|-
 
|00:33
 
|00:33
|I will come here, click on the folder called "mysql" and Save this as "connect.php"
+
|I will come here, click on the folder called "mysql" and '''save''' this as "connect.php".
 
|-
 
|-
 
|00:39
 
|00:39
|Now here we will create a separate file and include with every page that we use.
+
|Now, here we will create a separate file and include with every page that we use.
 
|-
 
|-
 
|00:45
 
|00:45
|This is a lot easier to connect to your database
+
|This is a lot easier to connect to your database.
 
|-
 
|-
 
|00:48
 
|00:48
|What we will do is type our "include" function and specify this file.
+
|What we will do is type our ''' "include" ''' function and specify this file.
 
|-
 
|-
 
|00:53
 
|00:53
Line 46: Line 46:
 
|-
 
|-
 
|00:59
 
|00:59
|Ok so I have got my mysql dot php open.
+
|Ok, so I have got my 'mysql dot php' open.
 
|-
 
|-
 
|01:03
 
|01:03
|This is php codes and we need the php tags and the same will connect to php
+
|This is '''php code''' and we need the '''php tags''' and the same will connect to '''php'''.
 
|-
 
|-
 
|01:10
 
|01:10
Line 55: Line 55:
 
|-
 
|-
 
|01:16
 
|01:16
|First, I will teach you how to connect to the database.
+
|First, I will teach you how to connect to the '''database'''.
 
|-
 
|-
 
|01:20
 
|01:20
|If you don't know where you have it stored on your webserver, then I suggest you check out an application called phpmyadmin.
+
|If you don't know where you have it stored on your web server, then I suggest you check out an '''application''' called '''phpMyAdmin'''.
 
|-
 
|-
 
|01:28
 
|01:28
|It is a database interface php written program or in other words a script.
+
|It is a '''database interface php''' written program or in other words a '''script'''.
 
|-
 
|-
 
|01:35
 
|01:35
|Here we will look at the inside of my database, my service.
+
|Here, we will look at the inside of my database, my service
 
|-
 
|-
 
|01:41
 
|01:41
|Rather my server, My SQL server.  It gives our table information, our database information and information about my server etc etc.
+
|rather my server, my '''SQL server'''.  It gives our table information, our database information and information about my server etc etc.
 
|-
 
|-
 
|01:55  
 
|01:55  
|Although, we don't need to know about it, this is a good start to a program, if you are just starting to use a php mysql or just mysql in general.
+
|Although, we don't need to know about it, this is a good start to a program, if you are just starting to use a '''php mysql''' or just '''mysql''' in general.
 
|-
 
|-
 
|02:06
 
|02:06
|It is a good way to start interfacing with your database, instead of using the command line to do things.
+
|It is a good way to start interfacing with your database instead of using the '''command line''' to do things.
 
|-
 
|-
 
|02:13
 
|02:13
|Using command line could be difficult for the first timers.
+
|Using '''command line''' could be difficult for the first timers.
 
|-
 
|-
 
|02:18
 
|02:18
|Ok, so what we see here are, our databases.
+
|Ok, so what we see here are our databases.
 
|-
 
|-
 
|02:23
 
|02:23
Line 85: Line 85:
 
|-
 
|-
 
|02:31
 
|02:31
|The others are just a standard.
+
|The others are just standard.
 
|-
 
|-
 
|02:34
 
|02:34
Line 94: Line 94:
 
|-
 
|-
 
|02:38
 
|02:38
|All you need to do is create new databases.  
+
|All you need to do is just create new databases.  
 
|-
 
|-
 
|02:41
 
|02:41
Line 103: Line 103:
 
|-
 
|-
 
|02:47
 
|02:47
|I will work within my php academy database for now.
+
|I will work within my "phpacademy" database for now.
 
|-
 
|-
 
|02:51
 
|02:51
Line 109: Line 109:
 
|-
 
|-
 
|02:53
 
|02:53
|So its creating a database now.
+
|So it is creating a database now.
 
|-
 
|-
 
|02:55
 
|02:55
|It is simple.
+
|It is simple.You type in the name and click on "Create".
|-
+
|02:56
+
|You type in the name and click on "Create".
+
 
|-
 
|-
 
|02:58
 
|02:58
Line 121: Line 118:
 
|-
 
|-
 
|03:01
 
|03:01
|So I will use this one.  
+
|So I will use this one.Click on it and you can see that there are several tables inside.
|-
+
|03:02
+
|Click on it and you can see that there are several tables inside.
+
 
|-
 
|-
 
|03:08
 
|03:08
|This is denoted by the symbol here when using phpmyadmin.
+
|This is denoted by the symbol here when using "phpmyadmin".
 
|-
 
|-
 
|03:15
 
|03:15
|This is guestbook from my guestbook tutorial.
+
|This is '''guestbook''' from my '''guestbook tutorial'''.
 
|-
 
|-
 
|03:21
 
|03:21
Line 136: Line 130:
 
|-
 
|-
 
|03:30
 
|03:30
|The number of fields is quite important.  
+
|The '''Number of fields''' is quite important.  
 
|-
 
|-
 
|03:33
 
|03:33
Line 142: Line 136:
 
|-
 
|-
 
|03:35
 
|03:35
|The number of fields on your table is for storing each column of data.
+
|The number of '''fields''' on your table is for storing each column of '''data'''.
 
|-
 
|-
 
|03:42
 
|03:42
|For example, the first one usually when you are dealing with records, you can have an ID which is a numerical value.
+
|For example, the first one usually when you are dealing with '''records''', you can have an ID which is a numerical value.
 
|-
 
|-
 
|03:51
 
|03:51
|So it is a number that is going to increment each time.
+
|So, it is a number that is going to increment each time.
 
|-
 
|-
 
|03:56
 
|03:56
Line 154: Line 148:
 
|-
 
|-
 
|04:02
 
|04:02
|And usually set this to the primary key.  
+
|And usually set this to the '''primary key'''.  
 
|-
 
|-
 
|04:06
 
|04:06
|If you are not familiar with the databases, you need to start looking out for terms like primary key.
+
|If you are not familiar with the databases, you need to start looking out for terms like '''primary key'''.
 
|-
 
|-
 
|04:14
 
|04:14
|I will not be dealing with secondary keys because its quite flexible way to do this anyway with mysql database.
+
|I will not be dealing with secondary keys because its quite flexible way to do this anyway with '''mysql database'''.
 
|-
 
|-
 
|04:22
 
|04:22
|Just read up on databases in general, if you have Microsoft access or any other database .  
+
|Just read up on databases in general, if you have '''Microsoft Access''' or any other database.  
 
|-
 
|-
 
|04:29
 
|04:29
Line 178: Line 172:
 
|-
 
|-
 
|04:47
 
|04:47
|The first one is always going be ID.
+
|The first one is always going to be '''id'''.
 
|-
 
|-
 
|04:50
 
|04:50
|This is a self incrementing value every time I create a new record.
+
|This is a self incrementing value, every time I create a new record.
 
|-
 
|-
 
|04:55
 
|04:55
Line 193: Line 187:
 
|-
 
|-
 
|05:08
 
|05:08
|So I will first type in the firstname and then I will type in the lastname and then the age and the gender.
+
|So I will first type in the '''firstname''' and then I will type in the '''lastname''' and then the '''age''' and the '''gender'''.
 
|-
 
|-
 
|05:17
 
|05:17
Line 199: Line 193:
 
|-
 
|-
 
|05:20
 
|05:20
|So here we can see that we have got 5 fields.
+
|So here we can see that we have got 5 '''fields'''.
 
|-
 
|-
 
|05:23
 
|05:23
|I shall go back here and type in 5 and click "Go".  
+
|I shall go back here and type in 5 and click '''Go'''.  
 
|-
 
|-
 
|05:28
 
|05:28
Line 217: Line 211:
 
|-
 
|-
 
|05:40
 
|05:40
|But, a field is a fieldname.
+
|But, a '''Field''' is a field name.
 
|-
 
|-
 
|05:42
 
|05:42
|So the first one is going to be "ID".
+
|So, the first one is going to be "id".
 
|-
 
|-
 
|05:45
 
|05:45
|The type is the data type, that you want to store this field in.
+
|The '''Type''' is the data type that you want to store this field in.
 
|-
 
|-
 
|05:49
 
|05:49
|Anything that goes into it must be added here to this datatype.
+
|Anything that goes into it must be added here to this data type.
 
|-
 
|-
 
|05:54
 
|05:54
|"varchar" which stands for variable characters is quite common.  It is a very useful one and it requires a length.
+
|"VARCHAR" which stands for variable characters is quite common.  It is a very useful one and it requires a length.
 
|-
 
|-
 
|06:00
 
|06:00
|We can have 25 characters long here.
+
|We can have 25 characters long here. 50 characters long.
|-
+
|06:03
+
| 50 characters long.
+
 
|-
 
|-
 
|06:02
 
|06:02
Line 247: Line 238:
 
|-
 
|-
 
|06:14
 
|06:14
|It helps in storing, for example your firstname.  
+
|It helps in storing, for example, your firstname.  
 
|-
 
|-
 
|06:17
 
|06:17
|Lets say our fieldname here is "firstname" and I have a "varchar".  
+
|Let's say our '''Field''' name here is "firstname" and I have a "VARCHAR".  
 
|-
 
|-
 
|06:24
 
|06:24
Line 256: Line 247:
 
|-
 
|-
 
|06:32
 
|06:32
|A typical firstname will be no  more than 25 characters.
+
|A typical first name will be no  more than 25 characters.
 
|-
 
|-
 
|06:36
 
|06:36
Line 265: Line 256:
 
|-
 
|-
 
|06:48
 
|06:48
|Our "ID" will be an integer because it is a number.
+
|Our "id" will be an integer because it is a number.
 
|-
 
|-
 
|06:53
 
|06:53
Line 274: Line 265:
 
|-
 
|-
 
|06:57
 
|06:57
|The amount of records we use.  
+
|the amount of '''records''' we use.  
 
|-
 
|-
 
|07:00
 
|07:00
Line 280: Line 271:
 
|-
 
|-
 
|07:03
 
|07:03
That is here is primary key.
+
|That is here is '''primary key'''.
 
|-
 
|-
 
|07:05
 
|07:05
|We are going to select it and at extra, we can see that we got "auto underscore increment".
+
|We are going to select it and at '''Extra''', we can see that we have got '''auto''' underscore '''increment'''.
 
|-
 
|-
 
|07:11
 
|07:11
|This is an auto increment.  
+
|This is an '''auto increment'''.  
 
|-
 
|-
 
|07:13
 
|07:13
Line 295: Line 286:
 
|-
 
|-
 
|07:21
 
|07:21
|So here we have "firstname".
+
|So, here we have "firstname".
 
|-
 
|-
 
|07:23
 
|07:23
Line 307: Line 298:
 
|-
 
|-
 
|07:34
 
|07:34
|Ok.
+
|Ok? Now here instead of "age", I will say, say "Date of birth" .
|-
+
|07:35
+
|Now here instead of "age", I will say say "Date of birth".
+
 
|-
 
|-
 
|07:40
 
|07:40
|So this is Date of Birth.
+
|So, this is Date of Birth (dob).
 
|-
 
|-
 
|07:43
 
|07:43
|I will set this as date.  
+
|I will set this as '''DATE'''.  
 
|-
 
|-
 
|07:45
 
|07:45
|Here I am  trying to find a date datatype and I will see how this works.
+
|Here, I am  trying to find a date data type and I will see how this works.
 
|-
 
|-
 
|07:51
 
|07:51
|So our length for date doesn't have to be set here.
+
|So, our '''Length''' for '''date''' doesn't have to be set here.
 
|-
 
|-
 
|07:54
 
|07:54
Line 328: Line 316:
 
|-
 
|-
 
|07:58
 
|07:58
|Now I will set the "gender" as "varchar" of character 1.
+
|Now I will set the "gender" as "VARCHAR" of character 1.
 
|-
 
|-
 
|08:05
 
|08:05
Line 343: Line 331:
 
|-
 
|-
 
|08:22
 
|08:22
|But usually name your fieldname appropriately so you know what data you are saving.
+
|But usually name your field-name appropriately so you know what data you are saving.
 
|-
 
|-
 
|08:28
 
|08:28
|Ok. Here I will click on "Save" and you can see that "people" has appeared here.
+
|Ok. Here I will click on '''Save''' and you can see that '''people''' has appeared here.
 
|-
 
|-
 
|08:35
 
|08:35
Line 367: Line 355:
 
|-
 
|-
 
|09:11
 
|09:11
|For example if I wanted to store everyone, I have registered here as male by default or female by default, I could type "M" or "F" here.
+
|For example, if I wanted to store everyone, I have registered here as male by default or female by default, I could type "M" or "F" here.
 
|-
 
|-
 
|09:21
 
|09:21
Line 373: Line 361:
 
|-
 
|-
 
|09:28
 
|09:28
|Ok here we have created our table and if you go in part II of this, I will show you how to insert some data and also how to retrieve this data from your database using php.
+
|Ok, here we have created our table and if you go in part II of this, I will show you how to insert some data and also how to retrieve this data from your database using php.
 
|-
 
|-
 
|09:40
 
|09:40
 
|Join me in part 2. This is Evan Varkey dubbing for the Spoken Tutorial Project. (Script contributed by Juanita Jayakar).
 
|Join me in part 2. This is Evan Varkey dubbing for the Spoken Tutorial Project. (Script contributed by Juanita Jayakar).

Latest revision as of 14:41, 10 March 2017

Time Narration
00:01 Hi everyone!
00:03 This is a pure MySQL php tutorial.
00:06 I will teach you the basics of connecting, retrieving data, handling errors and modifying data.
00:12 So, that will cover some SQL code and some SQL queries.
00:17 Ok! Let's start.
00:19 Here I am going to show the directory structure of "MySQL"
00:23 and we will create a couple of files here.
00:29 I will create the first file and call it "connect.php".
00:33 I will come here, click on the folder called "mysql" and save this as "connect.php".
00:39 Now, here we will create a separate file and include with every page that we use.
00:45 This is a lot easier to connect to your database.
00:48 What we will do is type our "include" function and specify this file.
00:53 I will create another file which is my main "mysql" file
00:57 with a code that I will show you all.
00:59 Ok, so I have got my 'mysql dot php' open.
01:03 This is php code and we need the php tags and the same will connect to php.
01:10 I will explain this "include" function in a minute.
01:16 First, I will teach you how to connect to the database.
01:20 If you don't know where you have it stored on your web server, then I suggest you check out an application called phpMyAdmin.
01:28 It is a database interface php written program or in other words a script.
01:35 Here, we will look at the inside of my database, my service
01:41 rather my server, my SQL server. It gives our table information, our database information and information about my server etc etc.
01:55 Although, we don't need to know about it, this is a good start to a program, if you are just starting to use a php mysql or just mysql in general.
02:06 It is a good way to start interfacing with your database instead of using the command line to do things.
02:13 Using command line could be difficult for the first timers.
02:18 Ok, so what we see here are our databases.
02:23 I have got one called "phpacademy" and I have got one called "phplogin" which I mentioned in another tutorial that I have created.
02:31 The others are just standard.
02:34 They are just for holding data.
02:36 Don't delete them.
02:38 All you need to do is just create new databases.
02:41 To do this, you have got a simple box here.
02:45 We are just going to create databases.
02:47 I will work within my "phpacademy" database for now.
02:51 It is a lot easier.
02:53 So it is creating a database now.
02:55 It is simple.You type in the name and click on "Create".
02:58 My php has already been created here.
03:01 So I will use this one.Click on it and you can see that there are several tables inside.
03:08 This is denoted by the symbol here when using "phpmyadmin".
03:15 This is guestbook from my guestbook tutorial.
03:21 Now I will create a new table on this database for the specifics of this tutorial and I shall call it "people".
03:30 The Number of fields is quite important.
03:33 You can't leave this blank.
03:35 The number of fields on your table is for storing each column of data.
03:42 For example, the first one usually when you are dealing with records, you can have an ID which is a numerical value.
03:51 So, it is a number that is going to increment each time.
03:56 It will allow you to reference your records being stored individually by the unique number.
04:02 And usually set this to the primary key.
04:06 If you are not familiar with the databases, you need to start looking out for terms like primary key.
04:14 I will not be dealing with secondary keys because its quite flexible way to do this anyway with mysql database.
04:22 Just read up on databases in general, if you have Microsoft Access or any other database.
04:29 I suggest you to learn about groups of database.
04:34 Ok, so the number of fields depends on how much data you want to store and what data you want to store.
04:39 Usually when I am creating fields, I will bring out an usual blank document.
04:44 And I will start by typing out the fields that I want.
04:47 The first one is always going to be id.
04:50 This is a self incrementing value, every time I create a new record.
04:55 So it will be 1 for the first record, 2,3,4 and the data will be stored after this.
05:00 It is a very useful field.
05:02 Since my table is called "people", I will store some data about people.
05:08 So I will first type in the firstname and then I will type in the lastname and then the age and the gender.
05:17 We can leave it there for now, to keep it simple.
05:20 So here we can see that we have got 5 fields.
05:23 I shall go back here and type in 5 and click Go.
05:28 It will also be great to see a pop up here in a minute.
05:31 No you won't because we haven't created our field names yet.
05:35 Ok! We have a standard here.
05:38 There are a lot of options for these.
05:40 But, a Field is a field name.
05:42 So, the first one is going to be "id".
05:45 The Type is the data type that you want to store this field in.
05:49 Anything that goes into it must be added here to this data type.
05:54 "VARCHAR" which stands for variable characters is quite common. It is a very useful one and it requires a length.
06:00 We can have 25 characters long here. 50 characters long.
06:02 Or 100 characters long.
06:04 Or 1 character long.
06:07 Actually we are just storing the type and the length of the data stored.
06:14 It helps in storing, for example, your firstname.
06:17 Let's say our Field name here is "firstname" and I have a "VARCHAR".
06:24 There is no point in typing in 500 characters because we will be using unnecessary amount of data.
06:32 A typical first name will be no more than 25 characters.
06:36 Even if it is, it will not be more than 30 or 35 characters.
06:41 But for now I will store my "firstname" as 20 to 25 characters and I will put 20 here.
06:48 Our "id" will be an integer because it is a number.
06:53 It will be self incrementing.
06:55 This will be 1,2,3,4
06:57 the amount of records we use.
07:00 And we have some other options here.
07:03 That is here is primary key.
07:05 We are going to select it and at Extra, we can see that we have got auto underscore increment.
07:11 This is an auto increment.
07:13 It will give this particular function.
07:16 Whenever you enter a new record, this will also automatically go up.
07:21 So, here we have "firstname".
07:23 We have "lastname" and again I will set this as 30.
07:27 And what else do we have???
07:29 We have "age" and obviously this is an integer and we have "gender".
07:34 Ok? Now here instead of "age", I will say, say "Date of birth" .
07:40 So, this is Date of Birth (dob).
07:43 I will set this as DATE.
07:45 Here, I am trying to find a date data type and I will see how this works.
07:51 So, our Length for date doesn't have to be set here.
07:54 We have a standard format for this. So we don't have to worry about that.
07:58 Now I will set the "gender" as "VARCHAR" of character 1.
08:05 Now we can store "M" for male and "F" for female.
08:12 Ok. If we go across here, we can see that there are a lots of options.
08:16 You can comment this yourself.
08:19 You can remind yourself what this field does.
08:22 But usually name your field-name appropriately so you know what data you are saving.
08:28 Ok. Here I will click on Save and you can see that people has appeared here.
08:35 This will ask you a query here.
08:38 Now when I was talking about command line earlier, this is what you have to type to create that.
08:46 However, we have used a graphic user interface to save ours.
08:50 We can see down here, we have our fields, our types and our collation attributes, null data for example.
08:59 The default value that is stored as.... say for example if you had a field saying "Has the user registered?"
09:07 Or anything of your choice. You could use the default here too.
09:11 For example, if I wanted to store everyone, I have registered here as male by default or female by default, I could type "M" or "F" here.
09:21 And we have auto increment here and also some other data that we don't need to know about in this tutorial.
09:28 Ok, here we have created our table and if you go in part II of this, I will show you how to insert some data and also how to retrieve this data from your database using php.
09:40 Join me in part 2. This is Evan Varkey dubbing for the Spoken Tutorial Project. (Script contributed by Juanita Jayakar).

Contributors and Content Editors

Minal, PoojaMoolya, Pratik kamble, Sakinashaikh, Sandhya.np14, Sneha