dongpan2788 2015-02-08 01:30
浏览 310

使用angularJS的可编辑表格单元格

Is there a way to show data inside td and allow user to edit it in a way that the change will take place in the sql (MySQL in my case) table? im creating a table from database using angularJS:

Creating The json file from the table:

$result = mysql_query("select * from `user script settings`");
//Create an array
$json_response = array();

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $row_array['user_id'] = $row['user id'];
    $row_array['script_id'] = $row['script id'];
    $row_array['cron_format'] = $row['cron format'];
    $row_array['schedule_last_update'] = $row['schedule last update'];
    $row_array['next_execution_time'] = $row['next execution time'];
    $row_array['script_exec'] = $row['script_exec'];

    //push the values in the array
    array_push($json_response,$row_array);
}
echo json_encode($json_response); 

showing it in the table:

<table class="table table-bordered table-hover">
    <thead>
        <td>user name</td>
        <td>script name</td>
        <td>cron format</td>
        <td>schedule last update</td>
        <td>next execution time</td>
        <td>script exec</td>
    </thead>
    <tbody>
        <tr ng-repeat="x in data">
            <td>{{x.user_id}}</td>
            <td>{{x.script_id}}</td>
            <td>{{x.cron_format}}</td>
            <td>{{x.schedule_last_update}}</td>
            <td>{{x.next_execution_time}}</td>
            <td>{{x.script_exec}}</td>
        </tr>
    </tbody>
</table>
<script>
    function customersController($scope,$http) {
        $http.get("getData.php")//test3.php return a json file of users table
                .success(function(response) {$scope.data = response;});
    }
</script>

I want to allow user to change the cron format value and to update the table ...is there "angularish" way to due that?? if not i'll appreciate guidance for a php solution, thx!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog