Angular Js applications – Insert, Fetch , Edit – update , Delete Operations

Good Morning To all,
The angular js is very useful framework to develope web applications. The angular js is a Javascript framework, we can buld well structured , maintainable ans easily testable front-end applications.

And Why Should I Use It?

If you are not try to develope application using angularjs yet, i really say you ae missing out. Its very useful and attractive,this will help you to build well structured, rich client-side applications in a modular fashion—with more flexibility and less code.



Today we focus, to develope SQL operations like insert, fetch, edit – update and delete operation using angularjs. All are familure, how to perform these operation via PHP code with javascript and ajax. And also we can develope these functionality via angualrjs with ajax.Its very simple and convenient.

Table Of Content

  • Insert the data into database
  • Read or Fetch the data from database
  • Edit And Update the existing data in database
  • Delete the data from database

In order to understand easily and effectively, we are going to create an application which will perform all the above-mentioned operation.

Insert the data into database

Everybody knows how to insert the data to the database using php using ajax with javascript. But nobody try to develope these operation using angularjs. AngularJs is very easy method to insert the data to the database via php page.
Here I explain this functionality via angularjsand and include output also .







my_file/user/add_user.php

first_name);
$last_name = mysqli_real_escape_string($conn, $data->last_name);
$email = mysqli_real_escape_string($conn, $data->email);
$userpassword = mysqli_real_escape_string($conn, $data->userpassword);
$userlevel=mysqli_real_escape_string($conn, $data->userlevel);

$query = "INSERT into shift_user(first_name,last_name,email,username,password,level,active) VALUES('$first_name','$last_name','$email','$email','$userpassword','$userlevel',1)";

mysqli_query($conn, $query);
echo true;
?>

The output as follows:
insert_query



Fetch/Read the data from database

From the above code everyone get an idea about angularjs and how to implement the applications using angularjs in php and get how to implement angularjs in ajax also.
Here we discuss how to get or fetch all the data from database using angularjs in php code.

	

my_file/user/user_details.php


The output as follows:
angular_fetch_all_data



Edit And Update the existing data in database

We already study how to insert, fetch the data from database using angularjs in php code. In here we discuss how to implement edit existing data then update in database.



my_file/user/update_user.php

user_id);

$first_name = mysqli_real_escape_string($conn, $data->first_name);
$last_name = mysqli_real_escape_string($conn, $data->last_name);
$email = mysqli_real_escape_string($conn, $data->email);
$userpassword = mysqli_real_escape_string($conn, $data->password);
$level=mysqli_real_escape_string($conn, $data->level);

$query = "UPDATE shift_user SET first_name='$first_name',last_name='$last_name',email='$email',username='$email',password='$userpassword',level='$level',active=1 WHERE user_id=$user_id";
mysqli_query($conn, $query);
echo true;
?>

The output as follows before updation:

angular_before_update




The output as foillows after successfully edit then update existing data
angular_after_update



Delete the data from database

	

my_file/user/delete_user.php

user_id";
mysqli_query($conn, $query);
echo true;
?>

Delete priya mary varghese from database. After successfully delete the output as follows:




angular_delete

Happy Coding

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

4 thoughts on “Angular Js applications – Insert, Fetch , Edit – update , Delete Operations

Leave a Reply

Your email address will not be published.