Inserting Multiple Mysql Rows Php Android
Im trying to insert multiple mysql rows in an external database using a php script and Android. I pass a JSONObject to the PHP script from Android and Im trying to use this data to
Solution 1:
Try this
$json = $_POST['json'];
$count=0;
$array = json_decode($json, true);
foreach ($array['person'] as$item){
$age= $item['age'];
$name= $item['name'];
$sql = "insert into Test4Upload(age,name) values('$age','$name')";
if(mysql_query($sql))
{
$count++;
}
}
return$count;
Solution 2:
Problem is thas you call return
after first loop:
if(mysql_query($sql)){
return1; // Return 1 for success;
}else{
return2;// Return 2 for database error;
and that return
breaks your loop. http://www.php.net/manual/en/function.return.php
Post a Comment for "Inserting Multiple Mysql Rows Php Android"