<?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-4_%2FEnglish</id>
		<title>PHP-and-MySQL/C3/MySQL-Part-4 /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-4_%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C3/MySQL-Part-4_/English&amp;action=history"/>
		<updated>2026-04-08T18:40:34Z</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-4_/English&amp;diff=555&amp;oldid=prev</id>
		<title>Chandrika: Created page with '{| border=1 !Time !Narration |- |0:0 |Welcome to the Spoken Tutorial on the fourth part of My SQL and php tutorials. |- |0:10 |In the last tutorial, I used &quot;mysql_query&quot; function…'</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C3/MySQL-Part-4_/English&amp;diff=555&amp;oldid=prev"/>
				<updated>2012-11-29T06:46:43Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;{| border=1 !Time !Narration |- |0:0 |Welcome to the Spoken Tutorial on the fourth part of My SQL and php tutorials. |- |0:10 |In the last tutorial, I used &amp;quot;mysql_query&amp;quot; function…&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;
|0:0&lt;br /&gt;
|Welcome to the Spoken Tutorial on the fourth part of My SQL and php tutorials.&lt;br /&gt;
|-&lt;br /&gt;
|0:10&lt;br /&gt;
|In the last tutorial, I used &amp;quot;mysql_query&amp;quot; function to insert some values into our table. &lt;br /&gt;
|-&lt;br /&gt;
|0:20&lt;br /&gt;
|I made a mistake here by putting the date as current date, which isn't my date of birth. &lt;br /&gt;
|-&lt;br /&gt;
|0:26&lt;br /&gt;
|I was able to update here. I was also able to specify where I wanted to update. &lt;br /&gt;
|-&lt;br /&gt;
|0:31&lt;br /&gt;
|Using a unique ID key, I was able to specify exactly where I wanted to update.&lt;br /&gt;
|-&lt;br /&gt;
|0:35&lt;br /&gt;
|So we've already seen the &amp;quot;update&amp;quot; in mysql code.&lt;br /&gt;
|-&lt;br /&gt;
|0:40&lt;br /&gt;
|This is very useful.&lt;br /&gt;
|-&lt;br /&gt;
|0:41&lt;br /&gt;
|This query and code is the one that is mostly used while working with tables or if you're working with mysql in general.&lt;br /&gt;
|-&lt;br /&gt;
|0:52&lt;br /&gt;
|The next thing I'll show you is how to get data from your table and how to display it really well.&lt;br /&gt;
|-&lt;br /&gt;
|1:04&lt;br /&gt;
|So I will call this &amp;quot;update data&amp;quot; so that we know what that is. &lt;br /&gt;
|-&lt;br /&gt;
|1:14&lt;br /&gt;
|Here, we will say &amp;quot;extract data&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|1:17&lt;br /&gt;
|That's a good word to use.&lt;br /&gt;
|-&lt;br /&gt;
|1:18&lt;br /&gt;
|Now, again we will say &amp;quot;extract&amp;quot; and we will create a variable. &lt;br /&gt;
|-&lt;br /&gt;
|1:24&lt;br /&gt;
|This again is &amp;quot;mysql query&amp;quot; and here is some code.&lt;br /&gt;
|-&lt;br /&gt;
|1:28&lt;br /&gt;
|This is slightly more complicated than using these single line queries.&lt;br /&gt;
|-&lt;br /&gt;
|1:37&lt;br /&gt;
|We use single line queries here, but we could have some code after this in order to display properly.&lt;br /&gt;
|-&lt;br /&gt;
|1:44&lt;br /&gt;
|First I will create another record in the table. &lt;br /&gt;
|-&lt;br /&gt;
|1:50&lt;br /&gt;
|So we don't need this &amp;quot;current date&amp;quot; function anymore. &lt;br /&gt;
|-&lt;br /&gt;
|1:52&lt;br /&gt;
|I need this &amp;quot;write&amp;quot; to be shown. Lets create some new value.&lt;br /&gt;
|-&lt;br /&gt;
|1:59&lt;br /&gt;
|I'll say &amp;quot;Kyle Headen&amp;quot; and I'll set a date of birth here. This one is month. So that is the 7th and lets say here, 24th.&lt;br /&gt;
|-&lt;br /&gt;
|2:16&lt;br /&gt;
|So now we got the date of birth.  &lt;br /&gt;
|-&lt;br /&gt;
|2:18&lt;br /&gt;
|Now we've got male and then we've got &amp;quot;Kyle Headen&amp;quot; and we are again inserting this into our database.&lt;br /&gt;
|-&lt;br /&gt;
|2:26&lt;br /&gt;
|Lets refresh.&lt;br /&gt;
|-&lt;br /&gt;
|2:28&lt;br /&gt;
|Here I'll create another new value.&lt;br /&gt;
|-&lt;br /&gt;
|2:32&lt;br /&gt;
|I'll say &amp;quot;Emily Headen&amp;quot; and I'll just leave the date of birth as it is for now. &lt;br /&gt;
|-&lt;br /&gt;
|2:44&lt;br /&gt;
|This will be &amp;quot;Female&amp;quot; because I'll extract these records at one point.&lt;br /&gt;
|-&lt;br /&gt;
|2:48&lt;br /&gt;
|Refresh this again.&lt;br /&gt;
|-&lt;br /&gt;
|2:50&lt;br /&gt;
|So we've created 3 records here.&lt;br /&gt;
|-&lt;br /&gt;
|2:53&lt;br /&gt;
|I'll comment this &amp;quot;write&amp;quot;. Backup my database.&lt;br /&gt;
|-&lt;br /&gt;
|2:56&lt;br /&gt;
|I'll click on browse in this specific table and you can see that I've got 3 records.&lt;br /&gt;
|-&lt;br /&gt;
|3:02&lt;br /&gt;
|Each one of these is called a &amp;quot;record of data&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|3:05&lt;br /&gt;
|We can see this id has also automatically incremented.&lt;br /&gt;
|-&lt;br /&gt;
|3:07&lt;br /&gt;
|We've got the data that we specified and everything that we need.&lt;br /&gt;
|-&lt;br /&gt;
|3:12&lt;br /&gt;
|Ok, so we are extracting data here and I will uncomment this.&lt;br /&gt;
|-&lt;br /&gt;
|3:19&lt;br /&gt;
|Our mysql query is going to start with &amp;quot;select&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|3:23&lt;br /&gt;
|This will be either specific records or we can use asterisk (*) to get all the data we need.&lt;br /&gt;
|-&lt;br /&gt;
|3:32&lt;br /&gt;
|Now I'll use an asterisk (*).&lt;br /&gt;
|-&lt;br /&gt;
|3:35&lt;br /&gt;
|What you could do is type &amp;quot;select firstname&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|3:40&lt;br /&gt;
|But usually, when you have table, you will need most of the data and it'll take longer to do.&lt;br /&gt;
|-&lt;br /&gt;
|3:46&lt;br /&gt;
|Depending on the source of the table, this won't take very long. &lt;br /&gt;
|-&lt;br /&gt;
|3:52&lt;br /&gt;
|So you already have a couple of records or fields. &lt;br /&gt;
|-&lt;br /&gt;
|3:55&lt;br /&gt;
|But for now I'll say select asterisk (*), which is a star. &lt;br /&gt;
|-&lt;br /&gt;
|4:00&lt;br /&gt;
|We can say select star and then we say FROM. &lt;br /&gt;
|-&lt;br /&gt;
|4:04&lt;br /&gt;
|Again we say, the specified table which is &amp;quot;people&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|4:08&lt;br /&gt;
|Here, we can say WHERE and how can you ummm...... filter for the data you want.&lt;br /&gt;
|-&lt;br /&gt;
|4:18&lt;br /&gt;
|So I can say &amp;quot;SELECT star (*) FROM people WHERE firstname= &amp;quot;Alex'&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|4:22&lt;br /&gt;
|This query will return only one value because we can see that if we open up here, there is only one record with &amp;quot;Alex&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|4:33&lt;br /&gt;
|We can do this by using another really useful function called &amp;quot;mysql numrows&amp;quot; and what I can do is echo this out.&lt;br /&gt;
|-&lt;br /&gt;
|4:44&lt;br /&gt;
|I'll say &amp;quot;echo mysql_num_rows&amp;quot;. This is the reason we have given these variables here to be stored in.&lt;br /&gt;
|-&lt;br /&gt;
|4:54&lt;br /&gt;
|Here we can just type &amp;quot;extract&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|4:56&lt;br /&gt;
|Our &amp;quot;extract&amp;quot; variable holds our query and our function here tells us how many rows are there in the query that is given out.&lt;br /&gt;
|-&lt;br /&gt;
|5:09&lt;br /&gt;
|Presuming that we gave firstname as &amp;quot;Alex&amp;quot;, it'll show when we refresh. &lt;br /&gt;
|-&lt;br /&gt;
|5:14&lt;br /&gt;
|However you get 1. &lt;br /&gt;
|-&lt;br /&gt;
|5:15&lt;br /&gt;
|Lets change this. Lets put something that's common to two people in this database.&lt;br /&gt;
|-&lt;br /&gt;
|5:21&lt;br /&gt;
|That would be the &amp;quot;gender&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|5:23&lt;br /&gt;
|So that'll be &amp;quot;Male&amp;quot; or &amp;quot;Female&amp;quot; . Here we can say &amp;quot;WHERE gender = M&amp;quot; and when we refresh, we get two records.&lt;br /&gt;
|-&lt;br /&gt;
|5:35&lt;br /&gt;
|So we can tell how many records we are getting out.&lt;br /&gt;
|-&lt;br /&gt;
|5:38&lt;br /&gt;
|This is really useful for saying how many people in my database are male, for example.&lt;br /&gt;
|-&lt;br /&gt;
|5:44&lt;br /&gt;
|And we can see how many males or females are registered to our website.&lt;br /&gt;
|-&lt;br /&gt;
|5:49&lt;br /&gt;
|So you can store registered information inside here. &lt;br /&gt;
|-&lt;br /&gt;
|5:55&lt;br /&gt;
|What we can also do is order the records.&lt;br /&gt;
|-&lt;br /&gt;
|5:59&lt;br /&gt;
|So I'll say &amp;quot;ORDER BY id&amp;quot; and we can choose descending that is &amp;quot;DESC&amp;quot; or we can choose ascending, which is &amp;quot;ASC&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|6:08&lt;br /&gt;
|But for now I'll take this out because we haven't actually echoed out our data yet. &lt;br /&gt;
|-&lt;br /&gt;
|6:13&lt;br /&gt;
|We haven't displayed out our data to the users that has been selected.&lt;br /&gt;
|-&lt;br /&gt;
|6:16&lt;br /&gt;
|So there is no point in using that at the moment.&lt;br /&gt;
|-&lt;br /&gt;
|6:19&lt;br /&gt;
|Now, here I'll say select star (*) from &amp;quot;people&amp;quot; because I want to select all the data from this table here. &lt;br /&gt;
|-&lt;br /&gt;
|6:29&lt;br /&gt;
|So I can manipulate and show it to the user the way I want.&lt;br /&gt;
|-&lt;br /&gt;
|6:31&lt;br /&gt;
|I'll create something here called &amp;quot;numrows&amp;quot;;  &amp;quot;numrows =&amp;quot; that.&lt;br /&gt;
|-&lt;br /&gt;
|6:42&lt;br /&gt;
|I'll use a &amp;quot;while&amp;quot; loop. This will use a specific function which is &amp;quot;mysql_fetch_assoc&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|6:58&lt;br /&gt;
|It puts this into an associative array.&lt;br /&gt;
|-&lt;br /&gt;
|7:02&lt;br /&gt;
|If you don't know what an associative array is, check out &amp;quot;Arrays&amp;quot; tutorial. &lt;br /&gt;
|-&lt;br /&gt;
|7:06&lt;br /&gt;
|Coming back,  &amp;quot;WHILE the row= mysql_fetch_aasoc&amp;quot; or associative is what I will say and this is inside the &amp;quot;extract&amp;quot; query.&lt;br /&gt;
|-&lt;br /&gt;
|7:21&lt;br /&gt;
|We are selecting &amp;quot;row&amp;quot; as array name and we are selecting this as an array for all the selected data.&lt;br /&gt;
|-&lt;br /&gt;
|7:31&lt;br /&gt;
|I'll stop here.  In the next tutorial I'll show you how to echo out this data. &lt;br /&gt;
|-&lt;br /&gt;
|7:37&lt;br /&gt;
|I'll probably explain this a bit more in detail.&lt;br /&gt;
|-&lt;br /&gt;
|7:40&lt;br /&gt;
|This is Juanita Jayakar dubbing for the Spoken Tutorial Project.&lt;/div&gt;</summary>
		<author><name>Chandrika</name></author>	</entry>

	</feed>