send arrylist values and fetch that array value in php

I am trying to get the values from php file.

I have a java file like this

ArrayList<NameValuePair> al = new ArrayList<NameValuePair>();

for (int i = 0; i < name.size(); i++) 
    al.add(new BasicNameValuePair("names["+i+"]",String.valueOf(name.get(i))));

    System.out.println("arr is " +String.valueOf(name.get(i)+ "arrrr"+name.get(i)));

here name is a arraylist.

now I want that name arraylist to be sent to php and loop that array and insert into database

this is my php file

$con = mysql_connect("localhost","aaa","aa");
mysql_select_db("aa", $con);

if (!$con)
    die('Could not connect: ' . mysql_error());

$arr[] = $_POST['names[]'];

foreach ($arr as $key) 
    $query="insert into Orders1(names) values('$key')";

it’s inserting "" (empty) value in database please help me.

Leave a Reply


Hire Me
Follow Me!
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.