第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用Angularjs在mysql中獲取特定id的數(shù)據(jù)

如何使用Angularjs在mysql中獲取特定id的數(shù)據(jù)

PHP
慕哥6287543 2021-06-16 17:15:55
我有一個基于 PHP angularjs 的 Web 界面,當(dāng)他們使用 angular 登錄時,我應(yīng)該獲取特定用戶的數(shù)據(jù)進(jìn)行編輯我所能做的就是 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 connectionsrequire_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 databaseconecho $json_info = json_encode($arr);?>我只想顯示與特定 id 相關(guān)的行,但我只能獲取所有行值并顯示它們并對其進(jìn)行編輯。我只希望具有唯一 ID 的特定用戶只能編輯行數(shù)據(jù)或?qū)⑵鋭h除。
查看完整描述

1 回答

?
海綿寶寶撒

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個贊

if在您的editInfo和deleteInfo方法中使用語句來檢查用戶的權(quán)限。這是一些偽代碼,可以為您提供想法:


$scope.permissionLevelRequired = 3;

$scope.userPermission = 1; // Get this from the database instead


$scope.editInfo(detail) {

  if ($scope.userPermission >= $scope.permissionLevelRequired) {

    // Make changes to `detail`

    ...

  }

}


$scope.deleteInfo(detail) {

  if ($scope.userPermission >= $scope.permissionLevelRequired) {

    // Make changes to `detail`

    ...

  }

}

這只是客戶端驗(yàn)證,它適用于您的界面目的,但很容易被黑客入侵。在更改數(shù)據(jù)庫之前,您可能還想驗(yàn)證服務(wù)器上的權(quán)限。


查看完整回答
反對 回復(fù) 2021-06-25
  • 1 回答
  • 0 關(guān)注
  • 104 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號