Web API – Adding Data

Dhoyazan Adbo Othman
A free video tutorial from Dhoyazan Adbo Othman
Senior Trainer and Developer at Pioneers Academy
4.2 instructor rating • 9 courses • 29,619 students

Learn more from the full course

Android Cars App using Kotlin, PHP and Google Maps

Kotlin, Volley, PHP, SMS and Google Map API with features like Uber taxi app

08:07:23 of on-demand video • Updated May 2018

  • Understand Kotlin Programming Language from Scratch
  • Implement OOP concepts in Kotlin
  • Create PHP web service connected to MySQL database
  • Create android app using Kotlin
  • Use Volley and Picasso libraries to get data from PHP web services
  • Use Google Map API
  • Send SMS
  • Add Run-time permissions
  • Create car service project for customer and employee
English [Auto] Hello everyone is with you. We are going to talk about how can we create a web if you are using ph B and connect those API to our database. The first video we have already created a database called text. And as you remember we have created tables called drivers inside this and also we have talked about how can we use the Esco Stedman. Let's add another driver for example and let's suppose that it is marked with this number OK. And click on go. So now we have two drivers inside our table. Now how can we add a third one. But using the Ph.D. in this case I'm going to use the net means. Of course you can use any ID. Now here the net means to create a new project just click on file and select new project. And then here on the left hand you'll see something called a DHV and on the right hand select DHV application and then select next no. Let's suppose that we are going to call this project as a ok. If I project and then go to the Prowse and you should put this project inside see inside 164 inside w w w inside this folder you should put your website. OK so now forward slash. And then again best which means create a folder with the name of our project inside the WMW and then click on finish. So don't forget to put your project inside see 164 WDW folder. Now how can we create a PH B file or a web file. In this case here on the left hand you will see or project with every project with a subfolder called source file just right click on the source fine. Select new and select BHB find. Let's suppose that we are going to call this file for example at and then click on free no how can we add a PH B file which will be used to add data inside our table. In this case I'm going to make many steps for that we have four steps which used mph be to add data from the HP file to the database. The first one called The Connection by using the connection or what you need to define a variable or an object mph be it a variable. Should start with the door sign. Of course if you want more information about creating a web site using BHB you can enroll in my course which is called DHB from zero to here. Anyway now to connect to database just use this line can equal my skill and then pass for Parminter. The first parameter is the server name which is localhost because I'm going to use my local datums. Then what is the username. The user name is route as you remember the previous videos when we log on to our database ask about the username and password the username by default is root and the password by default is empty string. Now what is my database name. My database name is taxi. So in this case I'm going to write the database name here which is tax. So this is the first STB which is called The Connection. This is the first tape which is called connection so the connection is how can we connect our webpage to the database using those for parliamentary server name username password and the database name. The second step is called the statement. And here we are going to use this called Esti define new object for the statement which is refer to the object connection with the function prepare and BHB this symbol which is called refer to or point to is used instead of docked in Scotland or in other programming language. So here is a prepare you should write your SQL statement. And here I'm going to write insert into drivers name Komer more by valiance one and two which means insert into the drivers table only for the name and the mobile. As you remember the previous we do is we make the ID as auto increment so we don't need to add data to the ID. Now what are the values you are going to add for the last name and move on. I have told him they are a web Borromeo source which means they are not defined and I am going to define them on runtime. The last thing or the third line here I am going to add or to define the parameters the parameters is how to define those customers by using the following functions which is called bind bottom in the byte from. We have two Barthes. The first part. What are the datatype of those question marks. I'm going to use s and again s because both name and more file are strings because when I create the database I have defined the name and Mumbai as a varchar. So this is the first part. The second part is using the system array or the global array which is called dollar sign and there's no underscore get and define the name of the variables or the columns which is name. So this statements means those two questionmark our strings. The first question mark. Define the name and the second question are defined the mobile. OK. And the last thing. Now is the execute which execute all the previous called by defining s.t. which is the statement referred to execute. Now let's try this example. Remember those four lines are always used when you are going to add or update or delete data to your table. So I'm going to change here. The Prowse are too crude. Then how can we run this file save. And then right click and select Run final here. I'm going to add 83 and then name equals. For example Ahmad more by a quas 4 5 4 5 7 8 8 0 0 9. And press enter. And we have got this empty beach. Now when we go to our database and click on the drivers table yes as you can see here aftermath with these more by number has been added. So in this video we have talked about how can we add a data from our HP be fired to the database. Please study this called multiple times because it is very important and we will need this called when we start our project which is the tax application. So see the next video.