1

I have seen couple of examples which takes form data to php server, but I don't see any example for sending arrayList of values to php server. Could anyone help me out ? I know how to do this:

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

I would like to do something like this :

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
nameValuePairs.add(new BasicNameValuePair("id", "12348"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "wassup"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

Plz help.

Thanks.

1 Answer 1

1

You can do something like this :

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();  
nameValuePairs.add(new BasicNameValuePair("colours[]","red"));  
nameValuePairs.add(new BasicNameValuePair("colours[]","white"));  
nameValuePairs.add(new BasicNameValuePair("colours[]","black"));  
nameValuePairs.add(new BasicNameValuePair("colours[]","brown"));  

where colour is your array tag. Just user [] after your array tag and put value. Eg. if your array tag name is colour then use it like colour[] and put value in loop.

Here is the link : Orignal Question

Sign up to request clarification or add additional context in comments.

2 Comments

How would I receive the same in Php webserver ?
For that you have to ask a separate question as I don't know about PHP. And if this answer solves your problem then please mark it as Accepted Answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.