title: INSERT multiple entries from Android -> PHP -> MYSQL
body: <p>I am trying to insert multiple (1-50) entries from an Android application to an external Mysql database. I perfectly got a PHP script to work for single INSERT queries. But I am failing so far to make this work for a whole array of entries, most likely due to my limited understanding of PHP.</p>
  
  <p>Android code:</p>
  
  <pre><code>List&lt;NameValuePair&gt; upload_array = new ArrayList&lt;NameValuePair&gt;();
  upload_array.add(new BasicNameValuePair("mFirstname[0]", "FirstName 1"));
  upload_array.add(new BasicNameValuePair("mFirstname[1]", "FirstName 2"));
  upload_array.add(new BasicNameValuePair("mLastname[0]", "LastName 1"));
  upload_array.add(new BasicNameValuePair("mLastname[1]", "LastName 2"));
  upload_array.add(new BasicNameValuePair("mNickname[0]", "NickName 1"));
  upload_array.add(new BasicNameValuePair("mNickname[1]", "NickName 2"));
  
  HttpClient httpclient = new DefaultHttpClient();
  HttpPost httppost = new HttpPost("http://url/script.php");
  HttpResponse response = null;
  try {
      httppost.setEntity(new UrlEncodedFormEntity(upload_array));
      response = httpclient.execute(httppost);
  } catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>And in PHP:</p>
  
  <pre><code>&lt;?php
  
  $connect = mysqli_connect("***","***","***", "***");
  
  if(mysqli_connect_errno($connect))
  {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  else
  {
      echo "success";
  }
  
  $query = mysqli_prepare("INSERT INTO `namelist` (`firstname`,`lastname`,`nickname`)
      VALUES(?,?,?)");
  
  $mFirstname = $_POST['mFirstname'];
  $mLastname = $_POST['mLastname'];
  $mNickname = $_POST['mNickname'];
  
  foreach($mFirstname as $key as $key =&gt; $value) {
      $query-&gt;bind_param('sss',$value["mFirstname"],$value["mLastname"],$value["mNickname"];
      $query-&gt;execute();
  }
  
  mysqli_close($connect);
  ?&gt;
  </code></pre>
  
  <p>Is the mistake happening in the Android part of the code already or does this PHP script just not read the data I sent properly? Any insight would be very welcome.</p>