Jump to content

EnSabahNur

New Members
  • Posts

    1
  • Joined

  • Last visited

EnSabahNur's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am trying to get data out off a mysql database, by using an php file. But i am not getting any output? Examples.html <html ng-app="countryApp"> <head> <meta charset="utf-8"> <title>Angular.js Example</title> <script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js"></script> <script> var countryApp = angular.module('countryApp', []); countryApp.controller('CountryCtrl', function ($scope, $http){ $http.get('category.php').success(function(data) { $scope.countries = data; }); }); </script> </head> <body ng-controller="CountryCtrl"> <table> <tr ng-repeat="country in countries"> <td>{{country}}</td> </tr> </table> </body> </html> category.php <?php $servername = "localhost:3306"; $username = "root"; $password = "root"; $dbname = "myDB"; $conn = mysqli_connect($servername, $username, $password, $dbname); if(!$conn){ die("Connection failed: " .mysqli_connecet_error()); } $showData = "SELECT id FROM myDB"; $data = array(); $result = mysqli_query($conn, $showData); if(mysqli_num_rows($result) > 0){ while($row = mysqli_fetch_assoc($result)){ $data[] = $row; } } else { echo "0 results"; }; print json_encode($data); mysqli_close($conn); echo($outp); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.