title: how to make your site be more live with angularjs?
body: <p>hello i am new in stackoverflow,
  i trying to build a chat system with HTML , CSS ,PHP &amp; angularjs
  but i stack in the middle
  my question is why my site doesnt live update with angularjs ?</p>
  
  <p>i trying to get a live select Query from SQL server and when i try to change the value to update the row noting happen in my site only if i am refreshing the site its change the records 
  maybe i dont have enough knowlegh about angularjs</p>
  
  <p><strong>How i should fix this problem ?</strong></p>
  
  <p>this is my script: index.html</p>
  
  <pre><code>&lt;html&gt;
  &lt;style&gt;
  table, th, td {
    border: 1px solid grey;
    border-collapse: collapse;
    padding: 5px;
  }
  table tr:nth-child(odd) {
    background-color: #f1f1f1;
  }
  table tr:nth-child(even) {
    background-color: #ffffff;
  }
  &lt;/style&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"&gt;&lt;/script&gt;
  &lt;body&gt;
  
  &lt;div ng-app="myApp" ng-controller="customersCtrl"&gt;
  
  &lt;table&gt;
    &lt;tr ng-repeat="x in names"&gt;
      &lt;td&gt;{{ x.Name }}&lt;/td&gt;
      &lt;td&gt;{{ x.Message }}&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/div&gt;
  
  &lt;script&gt;
  var app = angular.module('myApp', []);
  app.controller('customersCtrl', function($scope, $http) {
      $http.get("demo_index.php")
      .then(function (response) {$scope.names = response.data.records;});
  });
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>demo_index.php</p>
  
  <pre><code>    &lt;?php
   header("Access-Control-Allow-Origin: *");
  header("Content-Type: application/json; charset=UTF-8");
  
   //Connection details [SQL]
  $servername = "localhost";
  $username = "****************";
  $password = "***************";
  $dbname="**************";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password,$dbname);
  
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  }
  
  
  $sql = "SELECT * From chat" ;
  $outp = "";
  
  $result = $conn-&gt;query($sql);
  $num_rows = mysqli_num_rows($result);
  if($num_rows&gt;=0)
  {
      while($row = $result-&gt;fetch_assoc()){
  
       if ($outp != "") {$outp .= ",";}
      $outp .= '{"Name":"'  . $row["name"] . '",';
      $outp .= '"id":"'   . $row["id"]        . '",';
      $outp .= '"Message":"'. $row["message"]     . '"}'; 
      }
  
  
  
  
      $outp ='{"records":['.$outp.']}';
      }   
  
  
  $conn-&gt;close();
  
  
  
  
  echo($outp);
  
  ?&gt; 
  </code></pre>