I will call you back again to another lecture in PHP.
And in this video lecture we go ahead and look at the checkboxes.
So we have been able to discuss our arrays.
And from the knowledge of whatever we've learnt from arrays we're going to convert that to see the application
of arrays in checkboxes.
Now let me go ahead and create the form.
I'm going to start by creating a form right in here.
So let me go ahead and I say this is a form I'll go ahead and close my form.
So and that is closed.
And now I will go right inside the form and give it an action where the sites dot PHP which is a file
that is going to act on this.
Now we're going to use a method.
And that method continues right in here is going to be the post method.
So go ahead and use the post method.
So I told you, after we discuss the post method, that henceforth we are going to be using the post
method and no longer the Get method.
Now let's go ahead and discuss about cars.
So let me go ahead and say we have cars like our Toyota.
We have Nissan, we have Peugeot, we have Tesla and so on.
So let me go ahead and create this as a chat box that only when I click on any of the cars is going
to print it out.
And we're going to use just an array called cars for this.
Now let's go ahead and see.
The first one we have is a Toyota.
So I'm just giving a prompt.
And the next car is going to be Nissan.
So the next car is going to be Tesla.
And the the next car we're going to talk about I don't know more about this.
Just kind of see because all right.
So no after then for each of these cars we are going to input a checkbox.
So how do you add a checkbox to a task like having to click on Twitter?
So if we want to add a checkbox to that, you go ahead and put an input and the type of the input is
going to be a checkbox.
Oh, so let's go back.
And this is the A checkbox.
All right.
Now after an input you got to give it a name.
And that is where the variable name comes.
So the name is going to be is going to be the variable name.
Now let's go ahead and name this.
And I'm going to see this in our variable cause so this is another way I mean so the name is going to
be the array name.
And that is the cause.
So you go ahead and put a square bracket right in here.
Now you're going to specify inside a read element of this array.
And when you use code value.
And because the output in here is just a prompt.
So the value which is the element that will be specified inside the Inside a reef is going to be to
Utah.
All right.
So that is to Utah.
Go ahead and close this.
And I want to discuss on the next one.
So go ahead and put a brick so that the checkbox move to the next line.
So I'm going to copy whatever I have right in here.
Because what we need this guy and save this and refresh this page I check it out.
So I have to see I have to add a checkbox right in here.
You see that and I can click on that.
So let's go ahead and add a checkbox to Nissan Tesla and Pigeons.
So let's go ahead without wasting much time and copy whatever we have right in here.
And then go down here.
And then I paste that and change the value because that is the element name.
And now let's go ahead and name this to be Nissan.
So remember that this is just a prompt just to show out where you're selecting why.
The value right in there is what actually performs and show us what we are going to print out.
All right.
Now let's go ahead and move to the next one.
And I'll change that to Tesla.
We're going to change this to Tesla.
Right now.
We'll go to the next one and type in Bitcoin.
So we have number two dudes.
Let's go ahead and save this again.
I'll refresh this and check it out.
So we have our Toyota.
We have our Nissan.
We have Tesla and we have pictures.
You can see that can actually select that.
Now we'll go ahead and refresh this.
Now there's something important like I told you the first one here.
You can be able to give them different index.
Remember we're not we didn't arrange this in one file or in one.
The arrays are not just in one variable.
We have a car right in here.
We have car here.
Car here?
What?
Everything is just car.
So if I give this to be index zero, that means if I print this out, index zero is going to be two.
So if I give Tesla to be index zero.
So Tesla will always be printed out.
But if I leave this right in here it means that anyone I select to be printed out.
What if I want to print them out based on number of index?
I can say this is a zero, this is a one, this is two, and so on.
So now let's go ahead and move over to PHP right in here.
And the very first thing we're going to do on that PHP is to create a variable of cars.
Because this is just HTML and it's just a font created right in here.
Now we go over here and I use a dollar sign.
Let me say cars is going to be equal to dollar sign underscore posts.
No we're using post because we used those right in the A.
So if we use git that means we're going to use the Get method right in here.
Now let's go ahead and post in the the name which is right in here.
Which is cause because we're going to use just the same name right in here.
So cause that is really easy.
And then we go ahead and put a semicolon at the end.
Don't ever forget the semicolon.
So now if I want to exit this out so I'm go ahead and say echo.
Uh, don't say underscore cause and uh, you're going to put in the square bracket that this is an array.
And then I'm going to pass in zero and put a semicolon.
So like I told you I'm going to go back here and remove this zeros and ones I put in here.
And that is going to be just the same thing as it is.
So go ahead and save this and let us refresh this.
Go back to class and now grow a podcast.
We're in here because we didn't define crisis on define variable car.
All right.
Let's That's trying to save this.
And let's refresh this so you can see that the arrow is gone.
So I'm sorry about that.
So we have this and we have Tesla right in here.
And uh now if I select this guy and I select PGA and hit on submit I have PGA right in here.
Now if I click on Filter and submit I have data right in here.
And if I go ahead and click on this one I have this one here.
Now this will always print out one at a time.
You can see if I select a Tesla and select budget is going to print out the very first one I selected.
I hit submit and Tesla is printed out.
So anyone is select is going to print that out.
Now if I should go back right in here and say I want to give this as index index one.
So or let me go ahead and say index zero.
Let me give the third one, index zero.
And this guy had done 70s Unrefreshed days.
Now, if I print out this guy right here and I click on this and let's hit on this and print on this,
and you see that.
Now let's go ahead and change that to index one.
And let's go back here and change this to index one.
Save this and refresh.
Now what I have is an error because it says undefined library key one.
But if I should go over to Tesla and submit this, I have Tesla printed out.
And now I'm picking out elements of the index of index one.
Now, if I should go back to Toyota and submit, I have an error.
Can you see that until I go back in here and give Tesla maybe index two.
And now go back right in here and print out index two.
I will save this and refresh this.
So the error will be there.
So go back to Toyota and hit on submit.
And the theatre is printed out.
If I show that to anyone I want, I'm going to have an error.
Now let's go back and leave that at zero.
And, uh, so you can be able to give them different index.
But they are regardless of that, once you put in cause index zero it co-head and uh worked fine now
so it can be able to see that that works out fine.
So you can see that.
So anyone is select the very first one is select is going to be printed out for you.
So in this way you can be able to use uh checkboxes.
So this is just an introductory part of checkboxes in uh PHP.
All right.
So we can begin to do projects that uh gets heavier.
Uh, we're going to modify that more.
So we're just introducing this at this point.
And I believe that you understand something here.
So if you have any questions on this you can use the question and answer section.
And I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.