can u please give deleteData
can u please give deleteData(member.mem_id); function.
Its is missing from source code.
<!DOCTYPE html> <html lang = "en"> <head> <script src = "js/angular.js"></script> <script src = "js/app.js"></script> <meta charset = "UTF-8" name = "viewport" content = "width=device-width, initial-scale=1"/> </head> <body ng-app = "myModule" ng-controller = "myController"> <nav class = "navbar navbar-default"> <div class = "container-fluid"> <a class = "navbar-brand" href = "https://sourcecodester.com" >Sourcecodester</a> </div> </nav> <div class = "col-md-3"></div> <div class = "col-md-6 well"> <h3 class = "text-primary">AngularJS CRUD OPERATION WITH PHP/MySQLI - Part 2</h3> <hr style = "border-top:1px dotted #ccc;"> <form> <div class = "form-inline"> <label>Firstname</label> <input type = "text" class = "form-control" ng-model = "firstname" id = "firstname"/> <label>Lastname</label> <input type = "text" class = "form-control" ng-model = "lastname" id = "lastname"/> <button type = "button" class = "btn btn-primary form-control" ng-show = "btnInsert" ng-click = "insertData()"><span class = "glyphicon glyphicon-save"></span> Submit</button> <button type = "button" class = "btn btn-warning form-control" ng-show = "btnUpdate" ng-click = "updateData()"><span class = "glyphicon glyphicon-edit"></span> Update</button> <br /><br /> <div ng-model = "message" ng-show = "msgBox" class = "{{messageStatus}}">{{message}}</div> </div> </form> <br /> <table class = "table table-responsive table-bordered alert-warning"> <thead> <tr> <th>Firstname</th> <th>Lastname</th> <th></th> </tr> </thead> <tbody> <tr ng-repeat = "member in members"> <td>{{member.firstname}}</td> <td>{{member.lastname}}</td> <td><center><button type = "button" ng-click = "updateBtn(member.mem_id, member.firstname, member.lastname)" class = "btn btn-warning"><span class = "glyphicon glyphicon-edit"></span></button> <button type = "button" ng-click = "deleteData(member.mem_id);" class = "btn btn-danger"><span class = "glyphicon glyphicon-remove"></span></button></center></td> </tr> </tbody> </table> </div> </body> </html>
$scope.btnInsert = true; $scope.updateData = function(mem_id){ $scope.btnUpdate = false; $scope.btnInsert = true; $http.post("update.php", {mem_id: $scope.mem_id, firstname: $scope.firstname, lastname: $scope.lastname}) .then(function(response){ $scope.firstname = ""; $scope.lastname = ""; $scope.message = "Successfully Updated"; $scope.messageStatus = "alert alert-success"; $scope.msgBox = true; $timeout(function(){ $scope.msgBox = false; }, 1000); $scope.selectData(); }); } $scope.updateBtn = function(mem_id, firstname, lastname){ $scope.btnInsert = false; $scope.btnUpdate = true; $scope.firstname = firstname; $scope.lastname = lastname; $scope.mem_id = mem_id; }
<?php require_once 'connect.php'; $mem_id = $data->mem_id; ?>
<?php require_once 'connect.php'; $mem_id = $data->mem_id; $firstname = $data->firstname; $lastname = $data->lastname; $conn->query("UPDATE `member` SET `firstname` = '$firstname', `lastname` = '$lastname' WHERE `mem_id` = $mem_id") or die(mysqli_error()); ?>