title: inserting JSON decoded values into table
body: <p>This is my code of json decode and insert into the table after decoding. I am not getting how to insert implode values into table and nested json values .      </p>
  
  <pre><code>include 'config.php'; /* datdabase connection*/
      class User {
  public function update()
  {
      $jsondata = file_get_contents('data.txt');
      $data = json_decode($jsondata, true);
  $name=array();
      foreach($data as $item)
      {
  $name[]=$item['v'];
  
          }
  $val=implode(',',$name);
          echo"$val";
          $sql= mysql_query("INSERT INTO incident_main(inc_patientName,inc_patientAge,inc_patientGender,inc_patientMobile,inc_patientAddress,inc_patientWard,inc_type)  VALUES('..........') )");
          if(!$sql)
          {
              echo "Failed to insert the data into table";
  
      }
  }}
  
  $obj=new User(); 
  $obj-&gt;update()
  </code></pre>
  
  <p>This is my data.txt file. Here "n" is name of table  column and "v" is value which is to be inserted.</p>
  
  <pre><code>{
      "user_id": "user123",
      "time_stamp": "epoch",
      "lat": 52.25,
      "lon": 85.45,
      "mainreport":    [{
           "n": "date_of_diagnosis",
           "v": "epoch"
          },
          {
           "n": "name",
           "v": "abc"
          },
          {
           "n": "age",
           "v": 20
          },
          {
           "n": "gender",
           "v": "male"
          },
          {
           "n": "address",
           "v": "some address"
          },
          {
           "n": "location_gis_Stamp",
           "v": "word-1"
          },
          {
           "n": "mobile_number",
           "v": "some number"
          },
          {
           "n": "type_of_application",
           "v": "other",
           "nested": [{
               "n": "other",
               "v": "reason"
           }]}]}
  </code></pre>