android/php record not inserting into mysql

前端 未结 1 661
臣服心动
臣服心动 2020-12-18 12:06

I have a problem inserting my records into mysql table. Only the last record is being inserted.

This is the code I\'m working on:

Android

            


        
相关标签:
1条回答
  • 2020-12-18 12:31

    This is because you are making the HttpRequest only with the last parameter. (i.e) After your for loop is finished, params will contain only the last record. So Move the

    JSONObject json=jsonParser.makeHttpRequest(url_insertTo_outtrans,"POST",params);
    

    into the for loop.

    for(int i = 0; i < arrDocumentNumber.length; i++)
    {
     List<NameValuePair> params = new ArrayList<NameValuePair>();
     params.add(new BasicNameValuePair(TAG_DOCUMENTNUMBER, arrDocumentNumber[i] ));
     params.add(new BasicNameValuePair(TAG_TRANSACTIONDATE, arrTransactionDate[i] ));
     params.add(new BasicNameValuePair(TAG_ITEMCODE, arrItemCode[i] )); 
     JSONObject json=jsonParser.makeHttpRequest(url_insertTo_outtrans,"POST",params);
    }
    
    0 讨论(0)
提交回复
热议问题