Hi I'm trying to insert the json array into my MySQL database I'm new for this php development i have seen so many methods that all little confusing please help me out.
This is my json data.
[{"name":"0","phone":"dsf","city":"sdfsdf","email":"dsf"},{"name":"13123123","phone":"sdfsdfdsfsd","city":"sdfsf","email":"13123123"}]
I want to inset this json array into my mysql database so i have used this code its not working please tell me how to make it done. My php code.
<?php
$json = file_get_contents('php://input');
$obj = json_decode($data,true);
$obj[0]['name'];
$obj[1]['phone'];
$obj[2]['city'];
$obj[3]['email'];
//Database Connection
require_once 'db.php';
/* insert data into DB */
mysql_query("INSERT INTO `db512172115`.`trial` (name, phone, city, email)
VALUES ('".$obj->{'name'}."', '".$obj->{'phone'}."', '".$obj->{'city'}."', '".$obj->{'email'}."')");
//database connection close
mysql_close($con);
//}
?>
This above code only have used to store the values into my database please help me out to resolve this problem.
Thanks.