title: Fetch data from database in php using angular js $http.get
body: <p>I am using angular js script to fetch data from external php file encoded in json in html page. I have used <code>$http.get(page2.php)</code> method to fetch json encoded array written in another file. But the problem is its not showing any output just a blank screen I dont know where am I doing wrong.</p>
  
  <p>Here's <code>page1.html</code></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  var app = angular.module('myapp',[]);
  app.controller('myctrl',function($scope,$http){
  $http.get('page2.php').success(function(response){
  $scope.names = response;
  });
  });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;   
  &lt;div&gt;
  &lt;table ng-app="myapp" ng-controler="myctrl" &gt;
  &lt;tr ng-repeat="x in names"&gt;
  &lt;td&gt;{{ x.id }}&lt;/td&gt;
  &lt;td&gt;{{ x.name }}&lt;/td&gt;
  &lt;td&gt;{{ x.age }}&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here's <code>page2.php</code></p>
  
  <pre><code>&lt;?php
  
  $con = mysqli_connect('localhost','root','','practice');
  if(!$con){
  die("couldnt connect".mysqli_error);
  }
  $query = "SELECT * FROM records";
  $result = $con-&gt;query($query);
  $r = array();
  if( $result-&gt;num_rows&gt;0){
  while($row = $result-&gt;fetch_assoc()){
  $r[] = $row;
  }
  }
  $res = htmlspecialchars(json_encode($r));
  echo $res;
  ?&gt;
  </code></pre>
  
  <p>I can't figure out where am I doing wrong.</p>