WEBVTT 00:00:07.550 --> 00:00:14.550 In this video we're going to learn how to populate a table using BHB So in the previous video we managed 00:00:14.550 --> 00:00:16.790 to create a table. 00:00:17.260 --> 00:00:17.950 OK. 00:00:18.060 --> 00:00:20.530 So at the moment our table is empty. 00:00:20.730 --> 00:00:25.830 So let's write some code to populate this table. 00:00:27.450 --> 00:00:35.030 So first we need to connect to the database and then we'd be able to populate our table. 00:00:35.280 --> 00:00:40.460 So it connects to the database we're going to use exactly the same code we used previously. 00:00:40.690 --> 00:00:42.080 OK 00:00:49.000 --> 00:00:51.180 if we refresh. 00:00:52.200 --> 00:00:56.760 You can see that we are connected successfully to our database. 00:00:56.970 --> 00:01:06.060 Now we are ready to populate our table so to populate the table we are going to create a query and then 00:01:06.170 --> 00:01:09.490 we go going to execute that query. 00:01:09.720 --> 00:01:15.900 So we are going to use more or less the same structure of this code we use to create the table is just 00:01:15.900 --> 00:01:18.680 copied and changes. 00:01:20.520 --> 00:01:21.850 So it's going to be the same code. 00:01:21.930 --> 00:01:24.930 Really the only thing that's going to change is the query 00:01:27.120 --> 00:01:28.890 . 00:01:31.680 --> 00:01:37.480 And everything else is going to be same apart from the success message. 00:01:37.500 --> 00:01:46.980 So when we put a new record inside our table we are just going to write a new row audit successfully 00:01:47.010 --> 00:01:48.120 on your record. 00:01:48.120 --> 00:01:49.770 I did. 00:01:51.300 --> 00:01:52.290 OK. 00:01:52.860 --> 00:02:00.490 So now to insert a new record inside our table we're going to use the school all keyword inserts. 00:02:01.770 --> 00:02:07.840 Ok into a by the name of our table. 00:02:09.210 --> 00:02:10.030 OK. 00:02:10.590 --> 00:02:13.410 And then we're going to have brackets. 00:02:13.440 --> 00:02:20.740 And then inside the brackets we are going to specify all the fields we want to insert. 00:02:20.790 --> 00:02:26.610 So for example we on scene says the first name. 00:02:28.380 --> 00:02:31.770 OK let's make sure we gets all the field 00:02:36.000 --> 00:02:40.460 names correct So first name we don't score. 00:02:41.210 --> 00:02:49.890 And we want to insert last name email and password. 00:02:50.230 --> 00:02:51.050 OK. 00:02:51.180 --> 00:02:53.760 And then we're going to use the key word values 00:02:53.760 --> 00:02:59.210 . 00:02:59.220 --> 00:03:06.390 Pay forward by brackets again and then inside the brackets we're going to specify the values OK corresponding 00:03:06.390 --> 00:03:07.200 to these fields. 00:03:07.380 --> 00:03:08.670 We want to insets. 00:03:08.670 --> 00:03:12.880 So let's go for first name first. 00:03:13.950 --> 00:03:20.210 So everybody is going to go inside single quotes like that's OK. 00:03:20.670 --> 00:03:22.360 Let's go for pizza for example. 00:03:22.740 --> 00:03:26.250 And then we separate them using commas as well. 00:03:26.250 --> 00:03:40.400 Second one also inside single quotes Tyler and the email inside quotes for example sila doats pizza 00:03:41.050 --> 00:03:43.350 at G.M.. 00:03:43.380 --> 00:03:46.220 Those come on 00:03:49.210 --> 00:03:52.500 all of those tests whatsoever. 00:03:52.650 --> 00:03:58.650 And then finally we need the password and this is right. 00:03:58.660 --> 00:04:04.820 Any anything with the password password for example. 00:04:05.460 --> 00:04:07.840 OK so that's our query. 00:04:08.160 --> 00:04:10.110 So we execute the query. 00:04:10.200 --> 00:04:18.380 Then we check if it was executed successfully then we write we echo this paragraph. 00:04:18.510 --> 00:04:21.890 Otherwise we echo the error message. 00:04:22.110 --> 00:04:31.190 So let's save and refresh our page and we can see Nuro added successfully. 00:04:31.210 --> 00:04:39.440 Let's go back to our PSP my admin is refresh the page. 00:04:41.110 --> 00:04:47.650 OK so if we click on users. 00:04:51.360 --> 00:04:54.370 Now if you go to the Escurial tab. 00:04:55.290 --> 00:04:55.970 OK. 00:04:56.250 --> 00:05:00.660 So to retrieve all the data inside that table this is the query to use. 00:05:00.690 --> 00:05:04.230 OK so selects stuff from uses where 1. 00:05:04.230 --> 00:05:12.250 So if we click on go there we can see our table there with all the records inside the table. 00:05:12.600 --> 00:05:13.160 OK. 00:05:13.440 --> 00:05:23.810 So if we run the query again by refreshing the page and then we go back and then refresh. 00:05:25.630 --> 00:05:36.970 OK let's go back as well as goes to the users table is Cuil will go and I can see another record there 00:05:37.000 --> 00:05:37.430 . 00:05:37.840 --> 00:05:38.090 OK 00:05:41.820 --> 00:05:45.850 let's change our carrier and it's another different record. 00:05:45.870 --> 00:05:47.250 So it's odd for example 00:05:49.980 --> 00:05:50.550 Mark 00:05:54.330 --> 00:05:57.470 Zuckerberg for example and 00:06:03.110 --> 00:06:12.120 it's the same password save every refresh the page on your it successfully. 00:06:12.420 --> 00:06:20.340 Let's check again our table and you'll see that you're going to have three records. 00:06:20.770 --> 00:06:25.410 OK. 00:06:25.460 --> 00:06:31.750 He got three recalls There it is regarding the IDs and also Crimmins field so we started the first one 00:06:31.750 --> 00:06:34.700 and was given one of the two and then three. 00:06:35.460 --> 00:06:37.610 OK. 00:06:39.240 --> 00:06:39.810 All right. 00:06:39.900 --> 00:06:45.090 So in the next video we're going to learn how to populate our table using a form