<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=PHP-and-MySQL%2FC3%2FMySQL-Part-1%2FEnglish</id>
		<title>PHP-and-MySQL/C3/MySQL-Part-1/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=PHP-and-MySQL%2FC3%2FMySQL-Part-1%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C3/MySQL-Part-1/English&amp;action=history"/>
		<updated>2026-04-06T01:16:41Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

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

	</feed>