title: Encoding a Web Form in JSON
body: <p>I have a web form which reads values in from a database and displays them in boxes which I want to eventually allow the user to edit and save.</p>
  
  <p>Currently the user selects the ID of the record and one of the fields works fine, how do I encode this form in JSON to display the entire record when the ID is inserted? Thanks </p>
  
  <p>My current front-end code -</p>
  
  <pre><code> var id=jQuery("#myid").val();
   jQuery.getJSON('find.php',{num:id},function(obj){
  
  if (obj.length&gt;0){ 
   jQuery("input.fname").val(data); 
   jQuery("input.sname").val(data); 
   jQuery("input.age").val(data); 
    } 
  
  });
  </code></pre>
  
  <p>Back - end code - </p>
  
  <pre><code> $id = $_GET['id'];
  
   $query = "SELECT * FROM Customers WHERE ID = $id";
  
   $result = array('FirstName' =&gt; 1, 'Surname' =&gt; 2, 'Age' =&gt; 3);
  
   echo json_encode($result);
  </code></pre>
  
  <p>Where's my mistake?</p>