title: how to display in json format using php
body: <p>using php database connection i want to display data in json format which data are fatched from database(MySql),but i can't displaying in json format. <a href="http://takeyourtime.16mb.com/fatchData.php" rel="nofollow">http://takeyourtime.16mb.com/fatchData.php</a></p>
  
  <pre><code>$con = mysqli_connect($host, $username, $pwd, $db) or die('Unable to connect');
  if (mysqli_connect_error($con))
  {
    echo "Failed to Connect to Database ".mysqli_connect_error();
  }
  
  $name = $_POST['Query'];
  $sql = "SELECT * FROM playerstb";
  $query = mysqli_query($con,$sql);
  
  if ($query)
  {
    $rows = array();
    while ($r = mysql_fetch_assoc($query)) {
      $rows['root_name'] = $r;
    }
  }
  
  echo json_encode($rows);
  
  mysqli_close($con);
  </code></pre>