Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy AngularJS Tutorials</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> </head> <body ng-app="updateApp" ng-controller="updateCtrl"> <h1>MYSQL Update with PHP in AngularJS</h1> <form name="userForm"> <p>Enter Name : <input type="text" ng-model="user.name"> </p> <p>Enter Mobile : <input type="text" ng-model="user.mobile"></p> <p>Enter Email : <input type="email" ng-model="user.email"></p> </form> <table border="1"> <tr> <th>Id</th> <th>Name</th> <th>Mobile</th> <th>Email</th> <th>Update</th> </tr> <tr ng-repeat="x in content"> <td>{{x.id}}</td> <td>{{x.name}}</td> <td>{{x.mobile}}</td> <td>{{x.email}}</td> <td><button ng-click="update(x.id)">Update</button></td> </tr> </table> <h3>Please Use Ctrl+F5 for Refresh.</h3> </body> <script> var App = angular.module('updateApp', []); App.controller('updateCtrl', function($scope, $http) { $http.get("select.php").then(function(response) { $scope.content = response.data.details; }); $scope.update = function(value) { $http({ method : 'POST', url : 'update.php', data : {value: value, name: $scope.user.name, mobile: $scope.user.mobile, email: $scope.user.email}, headers : {'Content-Type': 'application/x-www-form-urlencoded'} }).success(function(data) { $scope.content = data; }); }; }); </script> </html>
www.wikitechy.com © Copyright 2016. All Rights Reserved.