Php 如何在angularjs中从数据库添加新行?

Php 如何在angularjs中从数据库添加新行?,php,mysql,angularjs,Php,Mysql,Angularjs,我想在表中添加新行。其中表数据来自数据库。如下所示 <div class="form-group form-horizontal" id="item" style="margin: 5px;"> <label class="col-xs-2 control-label">Enter Barcode:</label> <div class="col-xs-2 selectContainer"> <input ty

我想在表中添加新行。其中表数据来自数据库。如下所示

<div class="form-group form-horizontal" id="item" style="margin: 5px;">
    <label class="col-xs-2 control-label">Enter Barcode:</label>
    <div class="col-xs-2 selectContainer">
        <input type="text" class="form-control" ng-model="barcode" placeholder="enter barcode" />
    </div>
    <label class="col-xs-1 control-label">Quantity</label>
    <div class="col-xs-2 selectContainer">
        <input type="text" class="form-control" ng-model="qnt" ng-blur="putQnt()" placeholder="enter quantity" />
    </div>
    <button class="col-xs-1 btn btn-primary" ng-click="getInfo()">OK</button>
    <button class="btn btn-primary" ng-click="addItem()">Add Item</button>
</div>
现在,当我添加新行时,它会覆盖数据。我没有获得合并数据。因此,如何根据条形码条目从数据库中添加新行。请为
addItem()
函数提供一些建议。

您可以这样做:

$http.get("../POS_System/widget/bill.php?barcode="+$scope.barcode).success(function(data){
    var tempvar = data;
    var len = (tempvar.length);
    if(len>0) {
         for(var loop=0;loop<len;loop++) {
             $scope.data.push(tempvar[loop]);
    }  
        }); 
$http.get(“../POS\u System/widget/bill.php?barcode=“+$scope.barcode”)。成功(函数(数据){
var tempvar=数据;
变量len=(临时变量长度);
如果(len>0){

对于(var loop=0;loop请添加附加项函数请阅读我对该函数提出的问题。该函数是什么?使用了什么response.data?因为我得到了错误。@SureshKamrushi@KrishPatel:更新了与变量匹配的答案。
$http.get("../POS_System/widget/bill.php?barcode="+$scope.barcode).success(function(data){
    var tempvar = data;
    var len = (tempvar.length);
    if(len>0) {
         for(var loop=0;loop<len;loop++) {
             $scope.data.push(tempvar[loop]);
    }  
        });