title: How can I display Data from mysql using json
body: <p>How can I display data from the database using json php and mysql .
  I have been trying but I am failing to win but if I don’t include jquery it displays but in a funny way .
  I will appreciate for any help .
  Bellow is what I have tried so far. </p>
  
  <pre><code>&lt;?php 
  require_once('dbbox.php');
  ?&gt;
  &lt;?php
  $sql = "SELECT * FROM 
  m1debtors INNER JOIN 
  m1dtrans 
  ON m1debtors.name = m1dtrans.user";
  $result = mysql_query($sql, $con) or die(mysql_error($con));
  while ($row = mysql_fetch_array($result)){
  $accnum =  $row['accnum'];
  $name = $row['name'];
  $addr1 = $row['addr1'];
  }
  // The JSON standard MIME header.
  header('Content-type: application/json');
  $array = array('Name'=&gt;$name, 'user'=&gt;$user);
   echo  json_encode($array);
  ?&gt;
  Here is the html page to display data 
  &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
  $.getJSON("view.php",{$name});
  });
  &lt;/script&gt; 
  </code></pre>