OK, ladies and gentlemen, today, what we are going to do is we're going to discuss how these ideas,
we can make it dynamic, right?
So you don't have to write anything because I'm going to comment this part and I'm going to do something
here.
And this is just to show you how this is worked.
So bear with me.
I'm just going to explain why I'm going to do I'm just going to create a couple of instances of add
calories of this function constructor and we're going to push it back to the storage.
And after that, what we will expected here is I will explain how we can grab the how we can grab the
last study that we have inserted and what we will do next.
All right.
So manually, I'm going to you don't have to do this.
So I'm going to use this new gallery here.
I'm just going to copy it and I'm going to create new at Cal instance and I'm going to say, OK, zero
one, not one.
It's going to be through one.
What else?
135 in one.
So that will be the description.
That will be calories in the last one will be the quantity.
So I'm just going to paste it here a couple of more times.
I'm going to see one, two, three and four indeed will be one, two, three, four.
Now, this will be four, three, two, one.
And it should be zero, right?
I'm not going to change anything else because that is just the calories.
So now what we need to do is we need to push it to the storage storage.
So we're going to use the same here.
Same, same, same.
And instead of the type I was just going to add, I'm just going to use for this up.
Sorry for this for this area here.
I'm going to add four, five actually values here.
I'm going to push it the net new calorie, but I need to push it manually a couple more times.
So it will be one, two, three and four.
Now, I'm just going to control what I'm just going to control the D storage.
And this one here, I'm just going to comment because I'm controlling like twice.
Let's see what's happening now.
I have to enter something just to go there.
This is not going to be valid right now.
I do have here all calories.
I do have five items inside was going from zero to four.
So the idea should be.
So idea is this.
The idea should be last insert inserted idea plus one.
Right.
And how we can get this last insert ID.
So that is something that we need to consider because if I put it like this, if you go, this is not
some loop.
So you can go from zero to find this one, because if we just remove this one, the last idea will remain
same for.
So that's going to not going to change, right?
I'm just going to save it and I'm going to go back there.
So I do have for now, right?
But the last inserted idea is three.
So if I delete this one, it will be three for a start.
The last thing I did was for if I delete the first one again, the last answer that you will be for.
So I just want to find a way how we can get that last inserted idea and we can do that with the length.
So I'm going to show you.
So I'm going to create here another variable.
So cholerae length.
And I'm going to use this one here, I'm going to say war, not war, sorry.
Well, I'm thinking Kaleri and it will be equal to the storage, not all calories.
And based on this, for example, based on the type, I will get the length here.
I'm going to do it.
This right here.
Right here.
And I'm just going to Konza like these calorie.
Lori length, right?
So you should give me what's happening.
OK.
Something was stuck.
Sorry, ladies and gentlemen, I do have this for right because one we commented out.
So if I just take that one, I don't want to go through the same process again.
And I want to show you something else.
Right.
So it's four elements here.
One, two, three, four.
Now, what I want to do is actually to grab that I.D..
Well, how we can do this now.
I'm going to save the calorie array, so I'm going to create another variable here.
This is easier, easier for understanding.
So calorie and these calorie is actually will be like this.
So it will be storage that all calories.
And I'm going to say here type.
Right.
Now, the time is already being commented, and I'm going to see and we're going to change that later,
so I'm going to put it like this.
So in this case, I'll arrange this variable here.
I do have the I do have add or burn area.
So I'm going to store them and I'm going to use this one while I'm using this.
You will see at the moment now I'm going to see if it will be equal to these Kalari.
Right.
So I deal with this Kaleri and I already know the length cowl Kalari length that will be minus one inch.
I will grab the idea, simple as that.
So I'm going to cause a log.
Now you will see what will happen, right?
This is not magical, but we are not using the loops with loops.
It's everything is easy here is I grab the idea right now.
If we change this idea to seven, I'm going to grab the seven.
Right.
Although the average length is what is four?
Here is the drilling is for, but the I.D., the actual day that we let sorry we last inserted and that
is seven.
So now it's easy.
Now I know I've I've grabbed this idea in.
All I need to do is I need to incriminate about one.
Right.
So that is how I can get the next I.D. that I want.
So we have to with two possible scenarios.
What if this length is zero?
Right.
So if this length is zero, then what we need to do is actually to say, OK, if it's zero, then the
idea will be zero.
We're going to start from that idea.
So this will just for showing and I hope you understand it right.
I'm just going to I'm going to kill it from here.
Now, if you want to do it, just go back to the lecture, save it somewhere, because I'm not going
to give it to you.
It's not something that you want.
Yeah.
Let's I'm going to say cons of luck storage.
I don't need that one comes a lot and I don't need that one.
So I'm just going to copy to cut this uncommon this in here.
I'm just going to piece them right now.
I do have the calorie length in here.
I'm just going to change by type.
So I hope now you're getting what I'm trying to do and the idea I'm not going to do it like this, so
I have the idea variable here.
So grab this idea, but we need to wrap it up inside if condition.
Right.
So why need the length, for example?
So what we can do here, if calorie length is greater than zero, then I can do this, I can grab the
next item or else I eat.
I will initiate it.
I will I will get the value of this idea to be zero.
So that is pretty much all we need to do now.
Everything else will remain same.
So I do have the idea now.
So remember, we get the calorie length that storage all calories based on the type in the length.
And now I do have this calorie array I'm just getting by the time either will be burned or this one
in here.
I'm just saying calorie array minus one minus minus one of the length.
And I'm grabbing the idea and then I'm adding plus one.
If the calorie length is not greater than zero, that means that we are entering the first element for
this or this array in that will be zero right now.
Let's see.
So all I need to do is actually uncommon, this fella here, and let's hope it's going to work.
So I'm going to say food.
One hundred and fifty.
And I think it is I do have I expect the here to be zero because this condition is not met.
Right.
OK, now is going to come the interesting part, food, another other food example.
And it will be one.
It will be five five five.
We're going to hit enter.
And now I expect to have two items, but with different ideas.
Here is the idea is one, if we add ice cream, how cool is this?
Ladies and gentlemen, here, I will do have another one and it will go to that idea here.
Right now, one more thing.
Let's test it out for exercise.
Exercise one.
OK, I hit twice, maybe my mistake, so I'm going to see what's happening.
Yeah, here it is.
So I expect to have 011 with the same OK exercise, too.
And that will be 37 thirty.
Yeah, like that.
Something doesn't matter.
Now I just want to have three and here it is.
They're working.
So even the burn calories now everything is working.
So how cool is this.
Our application, ladies and gentlemen, start to look something like it.
You know, I'm just going to save it here like this.
So we grab the idea once more.
If the length is zero, then if it's greater than zero, we going to grab the last idea.
We're going to incremented one and else.
If it's the first in the area, we're going to grab zero.
And that's pretty much it here.
We explained last time what we are doing and that's pretty much it.
So we need to find a way how after what we have done here, we need to display somewhere.
Right.
We don't have it anywhere in this place right now.
That will be our goal to display these results, these items or calories as you want from on the on
the front or you are on the on the front.
You are.
So that's pretty much it.
Thank you for watching.
And I hope you understand if you don't please me, watch the video and I will see you in the next one.