title: PHP webservice with insert query
body: <p>I am new to coding, I am creating a webservice which will take 3 parameters and submit that into the database and revert with json response something like </p>
  
  <pre><code>{"Status":"Success", "Id":"123"}
  </code></pre>
  
  <p>currently i have code for selecting all tuple of a table and resulting in json using array(); but here i want object only (i guess), please help..</p>
  
  <p>attaching code of selecting data from database webservice,</p>
  
  <pre><code>$query = "SELECT id, name FROM table WHERE id = ".$user_id;
  $result = mysql_query($query,$link) or die('Error query: '.$query);
  $posts = array();
  if(mysql_num_rows($result)) {
      while($post = mysql_fetch_assoc($result)) {
          $posts[] = array('post'=&gt;$post);
      }
  }
  
      header('Content-type: application/json');
      echo json_encode(array('posts'=&gt;$posts));
  </code></pre>
  
  <p>Please help for creating webservice of insert data query. Thanks.</p>