Hi In my android application Iam retrieving the data from sqlite and now by using JSON i want to store that data into mysql table.Please help me to achieve this
I'm not getting how to store all the values in a table only single row is inserting each time I try to insert.
This is the code.
<?php
error_reporting(0);
include_once 'db_conn.php'; //Include the database connection strings
$received_json = $_POST["sparesJSON"];
if (get_magic_quotes_gpc())
{
$received_json = stripslashes($received_json);
}
$received_json = json_decode($received_json);
//catch variable
$item_name = $received_json[0]->item_name;
$quantity = $received_json[0]->quantity;
$total_price = $received_json[0]->total_price;
$cycle_id = $received_json[0]->cycle_id;
$date = $received_json[0]->date;
for($i=0;i<count($received_json;i++)
{
$insert_spares = "insert into spares_items (item_name, quantity, total_price, cycle_id, date) values (\"$item_name\", \"$quantity\", \"$total_price\", \"$cycle_id\", \"$date\")";
mysql_query($insert_spares);
}
//encode result array in json
echo json_encode($cycle_id);
//send this as an response to the Android
?>