You run MySQL of Query function and then in string right here our Query is going to be right here. So what we want to do is we want to insert a value and please follow along carefully because this maybe confusing to some. I want to get back to the structure so I can show you guys if that fails fields we’re going for, no ID we don’t need to edit that because that’s going to increment automatically as we said earlier the auto increment.
So basically the MYSQL Query I'm going to show you the basic Query that we are going to be using to day. Insert into are the first two keywords, that means we are going inserting into the database. Now next you want to specify your table, we’ve already selected the database TEST_DB so the next field down from that would be selecting the table, which is right here, TEMPDATA. And we basically want to type that in Back Take which if you don’t know what back Take, find the key on your keyboard that has the TILDIONIC which is that sign.
If you hold down shift and press that you’ll get utility but if you don’t hold, down shift you’ll get the Back Take when you press it. So Back Takes are to store the fields and regular thing will call store the values that is very important later on. So insert into, select the table name which will do Tempdata, you can see it right there. So we’ll put Tempdata and then another Back Take to enclose it so it’s complete, so we are going to insert into the table Tempdata, we want to put the field names now. And then we will put the value forms, since we only have one field name, we will use the number field name.
Now generally you’ll put parenthesis around this because you’ll generally have more fields input. And you put fields coma field coma field and you continue that on through out until your done with how many fields you’re going to insert into. And you put them in chronological order, so they’ll be going left or right and it will correspond with the values that we are going to input in the moment.
So go ahead and put the parenthesis and get used to that because we will be doing that a lot later on. And we need to select the field it’s going to be number; you see the field right here- here’s the number. And that’s going to be the field that will be inputting the value into. And we go ahead and put the where are- actually, we don’t need that, we need to put the values statement. So we are going to inside into the database Tempdata on the field number which I right there and we need to give it a value.
So the values is, used a single quote because their values and once again chronological order corresponding to the ones you put over here. So the firs one over here is number and it’s actually the only one, so on the values the first one once again is going to be the value we want to correspond with the first field, which is number. And where are you going to put the value of 80, so that is the MYSWL query it’s basically just going to insert the value of 80b into the Database.
Now this might seem confusing at first but once again give it time to settle in and it will start to make sense later on. So go ahead and that, I'm going to save in Instant Projects and we are going to save it as Databases1.php. Save as type change all files and click save, now in my projects folder I'm going to go ahead and refresh this and find my Database1.php. Now when we click this we got some errors here, I forgot to set my password so I'm want to do that now off the camera. Now I set my password so we refresh this page and nothing happens. Or so you think something happened, we just didn’t tell PHP to echo out anything on the screen. So what basically happened invisibly to what we can seen but if we go here to the Database we quick browse now, you’re going to notice that there’s a value here its either one so that increment it automatically from zero and the number is 80.
So we just inserted the value 80 into the Database, now we can keep refreshing this and it will keep running that query so I am going to refresh it again and again and again. So that should be for right now because we already did it once. Let’s quick browse again, you’ll scroll down and you’ll notice four numbers of 80 and the ID’s are automatically incrementing. Now that’s basically how you do it, it is very simple and there are a lot of different queries string and information you can run. You can retrieve that from the Database and execute command based on the data you’ve retrieved there’s just a lot you can do with MYSQL query.
And it’s stored in the database, which means it’s permanent unless you deleted from the Database so you can leave this Database and come back to years from now. And you’ll still find all this information now Database is are important because of the permanentness of them. And you can make a lot of different cool things like registration and log in systems could be on the PHP. Pretty much anything, you want I mean the possibilities are endless with PHP. You can create comments system on people’s profiles, different profiles, different things there’s a lot you can do and I am going to be showing you on how to do that later on.
And the ideas are important for retrieving the Data fields; you can run a query to select all of the data from ID3. And right now we just have the number field with 80 in it but that’s what it would retrieved. It would retrieve this entire row if we run that query and if we have a lot more information we could do things based on that information. But that’s basically Database is in the nutshell and right here the point of what you ran. This is why you can learn a little bit of it quickly on doing different things.
You can also, there’s a button over here if you click explain SQL then it will give you little more information about it as you can see. And going to skip on that, you can click create PHP code to make ti create the query based on that for you. So it created your PHP and also you can run you own SQL if you click up here this SQL button and you want tom run something. You can run your own SQL right here so we are going to select all from Tempdata we’re selecting all the values where something happens. We’ll do where ID=three and that’s basically we’re going select the entire row of Tempdata where ID=three.
And we’ll get in the more in that way later and go ahead click go and then it’s going to run the query and we will see the field that pop-up right here. ID=three the number 80 so we retrieve that row, thanks for watching the video guys.
I hope this wasn’t too confusing and I'm sorry for moving so quickly but I want to go ahead and get through PHP. And show us much information off as I can so you guys can go ahead and get started quickly. And begin your PHP journey so thanks for watching the video and I’ll have another one coming out.
Transcription by:
Scribe4you Transcription Services