doujiao1538 2016-12-29 05:43
浏览 32

如何使用JS进行更新与php mysql获取POST变量的值?

I want to update my table, and i have script in php page on my server for getting value like this

<div ng-controller="customersCrtl">
  <div class="container">
    <form method="post" action="update_mul.php">
      <td><input type="hidden" name="Id[]" value="{{data.Id}}" />{{data.Region}}</td>
      <td><input type="text" name="sii[]" value="{{data.Site_ID_Implementation}}"/></td>
    </form>
  </div>
</div>

and my update page is

<?php
    include_once 'connect.php';
    $id = $_POST['Id'];
    $sii = $_POST['sii'];
    $chkcount = count($id);
    for($i=0; $i<$chkcount; $i++)
    {
        echo $mysqli->query("UPDATE WS_Manado SET Site_ID_Implementation = '".$sii[$i]."'
                                        WHERE Id=".$id[$i]);
    }
?>

But this doesn't work, no error messagese or other just back to first page Firstly if i use <?php echo $row['Site_ID_Implementation'];?> on value, it's working

UPDATE app.js

var app = angular.module('myApp', ['ui.bootstrap']);

app.filter('startFrom', function() {
    return function(input, start) {
        if(input) {
            start = +start; //parse to int
            return input.slice(start);
        }
        return [];
    }
});
app.controller('customersCrtl', function ($scope, $http, $timeout) {
    $http.get('ajax/getCustomers.php').success(function(data){
        $scope.list = data;
        $scope.currentPage = 1; //current page
        $scope.entryLimit = 100; //max no of items to display in a page
        $scope.filteredItems = $scope.list.length; //Initially for no filter  
        $scope.totalItems = $scope.list.length;
    });
    $scope.setPage = function(pageNo) {
        $scope.currentPage = pageNo;
    };
    $scope.filter = function() {
        $timeout(function() { 
            $scope.filteredItems = $scope.filtered.length;
        }, 10);
    };
    $scope.sort_by = function(predicate) {
        $scope.predicate = predicate;
        $scope.reverse = !$scope.reverse;
    };
});

getCustomers.php

<?php
include('../connect.php');

$query="select distinct c.Region,c.Category,c.Site_ID_Implementation from WS_Manado c order by c.Id";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);

$arr = array();
if($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        $arr[] = $row;  
    }
}
# JSON-encode the response
$json_response = json_encode($arr);

// # Return the response
echo $json_response;
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)