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
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);
}