Hi All,
another angular newbie: 
I would like to write my first script with angular to see db data change 
without phisically reload my page :

<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");

require('../../config.php');
require($config['path'].'/db.inc.php');

$id  =  5;
$ids = 19;

$Q = ("SELECT idl,
              ids,
              shopN,
              Catalog,
              time,
              timei,
              ip,
              filename,
              filelast,
              filesize,
              filemd5,
              st,
              status FROM ftp_new_logs WHERE id='$id' AND ids='$ids' ORDER 
BY idl");

$q = mysqli_query($mysqli,$Q);

$outp = '';

        while ($row = mysqli_fetch_array($q,MYSQLI_BOTH)) {

                if ($outp != '') {
                $outp.= ',';
                }

        $outp .= '{"idl"      :"'.$row["idl"].'      ",';
        $outp .= ' "ids"      :"'.$row["ids"] .'     ",';
        $outp .= ' "Catalog"  :"'.$row["Catalog"].'  ",';
        $outp .= ' "time"     :"'.$row["time"].'     ",';
        $outp .= ' "timei"    :"'.$row["timei"].'    ",';
        $outp .= ' "ip"       :"'.$row["ip"].'       ",';
        $outp .= ' "filename" :"'.$row["filename"].' ",';
        $outp .= ' "filelast" :"'.$row["filelast"].' ",';
        $outp .= ' "filesize" :"'.$row["filesize"].' ",';
        $outp .= ' "filemd5"  :"'.$row["filemd5"].'  ",';
        $outp .= ' "st"       :"'.$row["st"].'       ",';
        $outp .= ' "status"   :"'.$row["status"].'   ",';

        $outp .=  '"shopN"    :"'.$row["shopN"].'    "}';
        }

$outp ='{"records":['.$outp.']}';

$mysqli->close();

echo($outp);

<!DOCTYPE html>
<html >

<style>
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;
}
</style>

<script src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js";
></script>
<body>
 
<div ng-app="myApp" ng-controller="customersCtrl">

<table>
  <tr ng-repeat="x in names">
    <td>{{ x.idl }}</td>
    <td>{{ x.ids }}</td>
    <td>{{ x.shopN }}</td>
    <td>{{ x.id }}</td>
    <td>{{ x.Catalog }}</td>
    <td>{{ x.time }}</td>
    <td>{{ x.timei }}</td>
    <td>{{ x.ip }}</td>
    <td>{{ x.filename }}</td>
    <td>{{ x.filelast }}</td>
    <td>{{ x.filesize }}</td>
    <td>{{ x.filemd5 }}</td>
    <td>{{ x.st }}</td>
    <td>{{ x.status }}</td>
  </tr>
</table>
 
</div>
 
<script>

var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
   $http.get("ftp_logs_json.php")
   .then(function (response) {$scope.names = response.data.records;});
});
</script>
 
</body>
</html>
these scripts work and any errors appears...
when I delete a row in my db I have to reload these 2 scripts to see that 
the deleted row is not ever in db...
question : How I can see db data change on the second script without 
phisically reload my page ?
always thanks
Gio

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to