<?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-6%2FEnglish</id>
		<title>PHP-and-MySQL/C3/MySQL-Part-6/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-6%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C3/MySQL-Part-6/English&amp;action=history"/>
		<updated>2026-05-14T17:43:47Z</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-6/English&amp;diff=559&amp;oldid=prev</id>
		<title>Chandrika: Created page with '{| border=1 !Time !Narration |- |0:00 |Hello Everyone! In the previous tutorial we had selected the data and we successfully displayed the data to our page. |- |0:07 |Let me take…'</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C3/MySQL-Part-6/English&amp;diff=559&amp;oldid=prev"/>
				<updated>2012-11-29T06:48:31Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;{| border=1 !Time !Narration |- |0:00 |Hello Everyone! In the previous tutorial we had selected the data and we successfully displayed the data to our page. |- |0:07 |Let me take…&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:00&lt;br /&gt;
|Hello Everyone! In the previous tutorial we had selected the data and we successfully displayed the data to our page.&lt;br /&gt;
|-&lt;br /&gt;
|0:07&lt;br /&gt;
|Let me take you back to this page here.We can see that everything is working fine.&lt;br /&gt;
|-&lt;br /&gt;
|0:11&lt;br /&gt;
|We have all our data here.&lt;br /&gt;
|-&lt;br /&gt;
|0:18&lt;br /&gt;
|The next thing we will learn is how to specify somewhere that the user themselves can enter and specify data. &lt;br /&gt;
|-&lt;br /&gt;
|0:25&lt;br /&gt;
|To do this, I will delete all the codes in my page except &amp;quot;connect include&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|0:32&lt;br /&gt;
|If I don't connect to my database, its not going to work.&lt;br /&gt;
|-&lt;br /&gt;
|0:35&lt;br /&gt;
|There is a lot of extracting and some other things to be found.&lt;br /&gt;
|-&lt;br /&gt;
|0:42&lt;br /&gt;
|I will retain firstname,  lastname, date of birth,  and gender either male or female. &lt;br /&gt;
|-&lt;br /&gt;
|0:51&lt;br /&gt;
|Below here, I will create a form. &lt;br /&gt;
|-&lt;br /&gt;
|0:58&lt;br /&gt;
|This will be an html form, so we need to start and end our tags. &lt;br /&gt;
|-&lt;br /&gt;
|1:01&lt;br /&gt;
|Our &amp;quot;action&amp;quot; will be &amp;quot;mysql dot php&amp;quot; and our &amp;quot;method&amp;quot; is going to be &amp;quot;POST&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|1:14&lt;br /&gt;
|Here we will create a form in which the user can specify a name.&lt;br /&gt;
|-&lt;br /&gt;
|1:25&lt;br /&gt;
|For the name we will use our &amp;quot;surname&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|1:28&lt;br /&gt;
|You can use any of them. For example, your date of birth or gender to search.&lt;br /&gt;
|-&lt;br /&gt;
|1:31&lt;br /&gt;
|It is your choice.&lt;br /&gt;
|-&lt;br /&gt;
|1:32&lt;br /&gt;
|You could even use 2 fields to search.&lt;br /&gt;
|-&lt;br /&gt;
|1:35&lt;br /&gt;
|I will now show you how to use 2 fields so that you know that it is not very complicated but easy.&lt;br /&gt;
|-&lt;br /&gt;
|1:41&lt;br /&gt;
|Here I will type &amp;quot;firstname&amp;quot; and I will create an &amp;quot;input&amp;quot; box of type &amp;quot;text &amp;quot; and the &amp;quot;name&amp;quot; of this will be &amp;quot;firstname&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|1:51&lt;br /&gt;
|We will create a break here and type &amp;quot;lastname&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|1:55&lt;br /&gt;
|Next we will create another input box  by copying the previous line and pasting it here.&lt;br /&gt;
|-&lt;br /&gt;
|2:01&lt;br /&gt;
|So this line is exactly the same  but instead of &amp;quot;firstname&amp;quot;, we type in &amp;quot;lastname&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|2:08&lt;br /&gt;
|We will type &amp;quot;input&amp;quot; type equals &amp;quot;submit&amp;quot; and the &amp;quot;value&amp;quot; of that will be &amp;quot;Get data&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|2:20&lt;br /&gt;
|Hence we have taken the &amp;quot;firstname&amp;quot; and &amp;quot;lastname&amp;quot; and the &amp;quot;submit&amp;quot; button.&lt;br /&gt;
|-&lt;br /&gt;
|2:25&lt;br /&gt;
|If I refresh this, we can see &amp;quot;Firstname&amp;quot; and &amp;quot;Lastname&amp;quot; has appeared.&lt;br /&gt;
|-&lt;br /&gt;
|2:29&lt;br /&gt;
|I will delete this for now and to do this I will check if the &amp;quot;submit&amp;quot; button has been pressed.&lt;br /&gt;
|-&lt;br /&gt;
|2:34&lt;br /&gt;
|To do this, I will first name the &amp;quot;submit&amp;quot; button as &amp;quot;submit&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|2:39&lt;br /&gt;
|Then I will type in an &amp;quot;if&amp;quot; statement - &amp;quot;if dollar underscore POST submit&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|2:51&lt;br /&gt;
|If the submit button has been pressed,  start the block.&lt;br /&gt;
|-&lt;br /&gt;
|2:55&lt;br /&gt;
|This is the block of code to be executed and we end our block where we want this to end.&lt;br /&gt;
|-&lt;br /&gt;
|3:02&lt;br /&gt;
|That is after this curly bracket here because that is a part of our &amp;quot;while&amp;quot; statement here.&lt;br /&gt;
|-&lt;br /&gt;
|3:08&lt;br /&gt;
|We don't actually need our while statement for this.  But I will still keep it for the sake of it.&lt;br /&gt;
|-&lt;br /&gt;
|3:17&lt;br /&gt;
|I will now type &amp;quot;grab POST data&amp;quot; and &amp;quot;dollar firstname&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|3:29&lt;br /&gt;
|So this is &amp;quot;dollar underscore POST firstname&amp;quot; and then I will type &amp;quot;lastname&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|3:40&lt;br /&gt;
|I will copy &amp;quot;firstname&amp;quot; and paste it here and change it to &amp;quot;lastname&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|3:43&lt;br /&gt;
|So we have got our &amp;quot;firstname&amp;quot; and &amp;quot;lastname&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|3:46&lt;br /&gt;
|I will type &amp;quot;echo&amp;quot; and this message &amp;quot;Record for firstname&amp;quot; . On second thoughts, let us not do this at the moment.&lt;br /&gt;
|-&lt;br /&gt;
|4:02&lt;br /&gt;
|I will go straight to my query here.&lt;br /&gt;
|-&lt;br /&gt;
|4:05&lt;br /&gt;
|If you remember, I had mentioned that you can specify what data you want in particular.&lt;br /&gt;
|-&lt;br /&gt;
|4:13&lt;br /&gt;
|For this, I will type &amp;quot;SELECT star FROM people WHERE firstname equals Alex and lastname equals Garrett&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|4:28&lt;br /&gt;
|I had not shown this inside this piece of query where we are selecting.&lt;br /&gt;
|-&lt;br /&gt;
|4:32&lt;br /&gt;
|I had shown it in the update  where we can update where the firstname equals &amp;quot;Alex&amp;quot; and the lastname equals &amp;quot;Garrett&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|4:38&lt;br /&gt;
|Now we will select everything we want from our table here and we will say select everything where our firstname is Alex to lastname is Garrett.&lt;br /&gt;
|-&lt;br /&gt;
|4:48&lt;br /&gt;
|If we look at our database here, we are searching for our firstname and matching it to &amp;quot;Alex&amp;quot;, searching the surname and matching it to &amp;quot;Garrett&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|4:56&lt;br /&gt;
|We are selecting this whole row of data over here which is highlighted in pink at the moment and we are just selecting the whole data from here.&lt;br /&gt;
|-&lt;br /&gt;
|5:08&lt;br /&gt;
|From the date of birth to gender, my id to my firstname and lastname.&lt;br /&gt;
|-&lt;br /&gt;
|5:11&lt;br /&gt;
|So we have understood that this will select only one record at this time, therefore we don't need to order by the &amp;quot;id&amp;quot;.  &lt;br /&gt;
|-&lt;br /&gt;
|5:19&lt;br /&gt;
|But I will keep it like that anyway, since there is only one record.  &lt;br /&gt;
|-&lt;br /&gt;
|5:24&lt;br /&gt;
|Ordering is not an issue,  so we can just leave it that way.&lt;br /&gt;
|-&lt;br /&gt;
|5:27&lt;br /&gt;
|Ok so we are running our loop, we are selecting each part of data here and we are changing our male to &amp;quot;male&amp;quot; and female to &amp;quot;female&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|5:35&lt;br /&gt;
|We are echoing out our data based on this query because this data based query is specific to my first and surname.&lt;br /&gt;
|-&lt;br /&gt;
|5:44&lt;br /&gt;
|Then we are only going to echo out the firstname and the lastname over here that has been found, which is my first and lastname but by changing &amp;quot;Alex&amp;quot; here to &amp;quot;firstname&amp;quot; which is here.&lt;br /&gt;
|-&lt;br /&gt;
|5:58&lt;br /&gt;
|Now that's a repetition. This is a double variable here.&lt;br /&gt;
|-&lt;br /&gt;
|6:01&lt;br /&gt;
|We have the &amp;quot;firstname&amp;quot; and so here, I will name this as &amp;quot;firstname underscore form&amp;quot; and &amp;quot;lastname underscore form&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
|6:07&lt;br /&gt;
|We will select from where the firstname has been posted equal to this and the lastname that we posted equal to lastname form.&lt;br /&gt;
|-&lt;br /&gt;
|6:16&lt;br /&gt;
|So this is the data that's come from our form.&lt;br /&gt;
|-&lt;br /&gt;
|6:18&lt;br /&gt;
|so if I were to type &amp;quot;Alex Garrett&amp;quot; in my html form and submit it then this will equal &amp;quot;Alex&amp;quot; and this will equal &amp;quot;Garrett&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|6:30&lt;br /&gt;
|Our query will return only one result because at the moment we have only one person named &amp;quot;Alex Garrett&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|6:37&lt;br /&gt;
|So it will take all the data for &amp;quot;Alex Garrett&amp;quot; and check for male or female and then echo out this particular message.&lt;br /&gt;
|-&lt;br /&gt;
|6:45&lt;br /&gt;
|So if I come here and refresh at the moment there is nothing because no data has been specified in these form variables here.&lt;br /&gt;
|-&lt;br /&gt;
|6:57&lt;br /&gt;
|Let me show you. These are empty therefore we are selecting &amp;quot;star&amp;quot; from people under this condition &amp;quot;WHERE the name equals to nothing and the lastname equals to nothing&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|7:08&lt;br /&gt;
|That has not returned any data at the moment because what we got in our firstname and lastname are actual peoples names.&lt;br /&gt;
|-&lt;br /&gt;
|7:18&lt;br /&gt;
|Anyway now I will just type in a completely random name.&lt;br /&gt;
|-&lt;br /&gt;
|7:23&lt;br /&gt;
|So lets say &amp;quot;David Green&amp;quot; and click get data and nothing has happened, ok?&lt;br /&gt;
|-&lt;br /&gt;
|7:29&lt;br /&gt;
|If we had an error message at the end over here,  this is our query written over here,  I could say &amp;quot;or die mysql error&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|7:41&lt;br /&gt;
|I go back here and say &amp;quot;David Green&amp;quot; and click get data and oh! we don't have an error!&lt;br /&gt;
|-&lt;br /&gt;
|7:49&lt;br /&gt;
|Oh yes that's because the structure of the sql code correct and so we don't get any error.&lt;br /&gt;
|-&lt;br /&gt;
|7:54&lt;br /&gt;
|I was just testing that out. &lt;br /&gt;
|-&lt;br /&gt;
|7:56&lt;br /&gt;
|Now lets suppose that we do have a name that's in our database.&lt;br /&gt;
|-&lt;br /&gt;
|8:00&lt;br /&gt;
|Lets say &amp;quot;Alex Garrett&amp;quot; and we click &amp;quot;Get data&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|8:05&lt;br /&gt;
|We are presented here with alex garrett was bron blah blah blah and is male.&lt;br /&gt;
|-&lt;br /&gt;
|8:10&lt;br /&gt;
|Lets type &amp;quot;Dale Garrett&amp;quot; and click &amp;quot;Get data&amp;quot; and we receive that information from the database.&lt;br /&gt;
|-&lt;br /&gt;
|8:17&lt;br /&gt;
|So you can see that this is very useful to incorporate forms into our data.&lt;br /&gt;
|-&lt;br /&gt;
|8:25&lt;br /&gt;
|I will stop here and go on to the next part where I will be talking about how to update records using this method.&lt;br /&gt;
|-&lt;br /&gt;
|8:38&lt;br /&gt;
|Many of you would be able to do that on your own by now but I will take you through it anyways along with a few other useful things.&lt;br /&gt;
|-&lt;br /&gt;
|8:44&lt;br /&gt;
|Ok so, see you soon.  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>