[Solved] how to insert Json object in database [closed]


Example of database connection :

       //ENTER YOUR DATABASE CONNECTION INFO BELOW:
         $hostname="localhost";
         $database="dbname";
         $username="username";
         $password="password";

   //DO NOT EDIT BELOW THIS LINE
     $link = mysql_connect($hostname, $username, $password);
     mysql_select_db($database) or die('Could not select database');

Exemple of INSERT array in database :

 $json = file_get_contents('php://input');
 $obj = json_decode($json,true);

 //Database Connection
require_once 'db.php';

 /* insert data into DB */
    foreach($obj as $item) {
       mysql_query("INSERT INTO `database product`.`table name` (productName, productPrice, quantity) 
       VALUES ('".$item['productName']."', '".$item['productPrice']."', '".$item['quantity']."')");

     }
  //database connection close
    mysql_close($con);

   //}

solved how to insert Json object in database [closed]