How to decode JSON in PHP and insert it into Mysql table?
<p>I am using the following code in PHP..its creating the file post.json ..but inserting values into the table is not reflecting..</p>

<pre><code>&lt;?php
$input = file_get_contents('php://input');
logToFile("post.json",$input);

$json_a=json_decode($input,true);

$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("mydb", $con);

mysql_query("INSERT INTO order_table (Table_id, Menu_Item_Name, Menu_Item_Price, Menu_Item_quantity) VALUES('$json_a[TableId]','$json_a[ItemName]','$json_a[ItemPrice]','$json_a[ItemQuantity]')");


function logToFile($filename,$msg)
{
      $fd=fopen($filename,"a");
      $str="[".date("Y/m/d h:i:s")."]".$msg;
      fwrite($fd,$str."\n");
      fclose($fd);
}

?&gt;
</code></pre>
