我有一个基于 PHP angularjs 的 Web 界面,当他们使用 angular 登录时,我应该获取特定用户的数据进行编辑
我所能做的就是 ng-repeat 获取所有 id 的所有行
控制器.js文件
var crudApp = angular.module('crudApp',[]);
crudApp.controller("DbController",['$scope','$http', function($scope,$http){
// Function to get employee details from the database
getInfo();
function getInfo(){
// Sending request to EmpDetails.php files
$http.post('databaseFiles/Details.php').success(function(data){
// Stored the returned data into scope
$scope.details = data;
});
}
index.php 文件
<tr ng-repeat="detail in details| filter:search_query">
<td>{{$index + 1}}</td>
<td>{{detail.trainer_name}}</td>
<td>{{detail.trainer_team}}</td>
<td>{{detail.trainer_code}}</td>
<td>
<button class="btn btn-warning" ng-click="editInfo(detail)" title="Edit">
<span class="glyphicon glyphicon-edit"></span>
</button>
</td>
<td>
<button class="btn btn-danger"
ng-click="deleteInfo(detail)" title="Delete">
<span class="glyphicon glyphicon-trash"></span>
</button>
</td>
</tr>
详情.php
<?php
// Including database connections
require_once 'database_connections.php';
// mysqli query to fetch all data from database
$query = "SELECT * from pokedstats";
$result = mysqli_query($con, $query);
$arr = array();
if(mysqli_num_rows($result) != 0) {
while($row = mysqli_fetch_assoc($result)) {
$arr[] = $row;
}
}
// Return json array containing data from the databasecon
echo $json_info = json_encode($arr);
?>
我只想显示与特定 id 相关的行,但我只能获取所有行值并显示它们并对其进行编辑。我只希望具有唯一 ID 的特定用户只能编辑行数据或将其删除。
海绵宝宝撒