如何使用angularjs和PHP来获得数组输入值到数据库 [英] how to get array input values into database using angularjs and PHP

查看:184
本文介绍了如何使用angularjs和PHP来获得数组输入值到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在其中的按钮输入字段的点击获取附加的形式。
的形式是如以下

I have a form in which on click of button input fields get appended. The form is as below.

<body data-ng-app="myApp" data-ng-controller="myController" >
<form name="educdetailsform" novalidate>
   <label>Education Details</label></br>
    <button ng-click="addfield()">Add Education</button>
     <div ng-repeat="item in items">
     <input type="text" name="qualification[]" data-ng-model="empData.qualification[]" placeholder="Qualification">
      <input type="text" name="year[]" data-ng-model="empData.year[]" placeholder="Year of Passing">
      <input type="text" name="percentage[]" data-ng-model="empData.percentage[]" placeholder="Percentage">
     </div> 
   <input type="submit" name="submit" ng-click="saveUser()" />
  </form>
</body>

角JS code的附加输入字段如下:

The angular JS code for appending input fields is as follows

 var module=angular.module('myApp',[]);
 module.controller('myController',function($scope, $http){
  $scope.items = [{}];

$scope.addfield = function(){
   $scope.items.push({});
}

 });

这是code和功能的 http://jsfiddle.net/b0jtqzpj/2 /

This is the code and functionality http://jsfiddle.net/b0jtqzpj/2/

如何获得田里saveUser()函数,然后使用PHP中的数据保存到数据库表
像,如果用户已经进入3项即,第一条目必须保存在一排和下排,并在第3行第3项中第2项。即,如果3项在HTML表单中输入并提交,必须在数据库表中创建3个条目。

How to get the fields to saveUser() function and then save the data into database table using PHP Like, if the user has entered 3 entries i.e, the first entry must be saved in a row and 2nd entry in next row and 3rd entry in 3rd row. i.e, if 3 entries are entered in html form and submitted, 3 entries must be created in database table.

如何在angularjs saveUser()函数赶数据,然后在数据库中使用PHP保存

How do I catch data in angularjs saveUser() function and then save in database using PHP

推荐答案

您可以检查JS小提琴的http:// jsfiddle.net/ss5yo9xk/4/ 制作Ajax调用,你需要低于code使用PHP在侧面得到POST数据:

You can check js fiddle http://jsfiddle.net/ss5yo9xk/4/ for making ajax call and you need to use below code at php side to get post data :

$postData = json_decode(file_get_contents('php://input'), true);

这篇关于如何使用angularjs和PHP来获得数组输入值到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆