Delete Data from MySQL Database Using AngularJS with PHP

Hi, friends in this post we going to learn how to delete data from MySQL database using AngularJS with PHP. If you are going to work with a web application using AngularJS & PHP on that you need to delete the data. So how can you delete the data using AngularJS with PHP? In this, post you can find how to delete the data. If you inserted some data into the database that you need to remove without page refresh, So using AngularJS we can do this very easily. The following example will explain you clearly.



<!doctype html>
<meta charset="UTF-8">
<title>Softaox | Delete Data from MySQL Database Using AngularJS with PHP</title> 
<link rel="stylesheet" href="" />  
<script src=""></script>
<div class="container">
	<h3 align="center">Delete Data from MySQL Database Using AngularJS with PHP</h3>
	<div ng-app="sa_delete" ng-controller="controller" ng-init="show_data()">
		<table class="table table-bordered">
				<th>Email ID</th>
			<tr ng-repeat="x in names">
				<td align="center">
					<button ng-click="delete_data( )"class="btn btn-danger">X</button>
<!-- Script -->
    var app = angular.module("sa_delete", []);
    app.controller("controller", function($scope, $http) {
        $scope.show_data = function() {
                .success(function(data) {
                    $scope.names = data;
        $scope.delete_data = function(id) {
            if (confirm("Are you sure you want to delete?")) {
                $"delete.php", {
                        'id': id
                    .success(function(data) {
            } else {
                return false;

 $conn = mysqli_connect("localhost", "root", "", "angularjs");  
 $output = array();  
 $query = "SELECT * FROM insert_emp_info";  
 $result = mysqli_query($conn, $query);  
 if(mysqli_num_rows($result) > 0) {  
      while($row = mysqli_fetch_array($result)) {  
           $output[] = $row;  
      echo json_encode($output);  

 $conn = mysqli_connect("localhost", "root", "", "angularjs");  
 $info = json_decode(file_get_contents("php://input"));  
 if(count($info) > 0) {  
      $id = $info->id;  
      $query = "DELETE FROM insert_emp_info WHERE id='$id'";  
      if(mysqli_query($conn, $query)) {  
           echo 'You data has successfully been deleted..';  
      } else {  
           echo 'Failed';  

Was this article helpful?

Yes No

How can we improve it?


We appreciate your helpul feedback!

Your answer will be used to improve our content. The more feedback you give us, the better our pages can be.

Follow us on social media:

Facebook Pinterest
Share via:


Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts.

Leave a Reply