Android : Post Array to php with JSON

on Thursday, September 4, 2014


I want to send an Array to a php file. I can do it with a single string, so the connection etc. works. But i dont know how to do it with an array and how to get the array at the php file.


So this is my class:



String[] nonUserArray = new String[ohne.size()];
for (int i = 0; i < ohne.size(); i++) {

nonUserArray[i] = ohne.get(i).getnummer();
System.out.println("Array "+nonUserArray[i]);
}


List<Name ValuePair> params = new ArrayList<NameValuePair>();
// This is still wrong...
params.add(new BasicNameValuePair("nummer[]", nonUserArray[]));


My php file still is:



<?php
$response = array();
if (isset($_POST['nummer'])) {
$nummer = $_POST['nummer'];
require_once __DIR__ . '/db_connect.php';

$db = new DB_CONNECT();

//Hier wird die ID ausgelesen
$getIdAusMySQL = 0;
$getIdAusMySQL = mysql_query("SELECT id FROM User WHERE nummer = '$nummer'");

...


I dont know how to receive the array and put it in a loop inside the php file.


´ By the way, can someone tell me a good oppertunity to find errors inside a php file. something like system.out.println() in java/android. Thanks


0 comments:

Post a Comment