hope you fine and well ,
i want to ask if it possible to fetch data using $http.get from the same page , to go deep in details :
i have a php file called (MY_FILE.php) that contains : PHP,HTML and SCRIPT codes , in the PHP section i executed sql select statment, and im trying to fetch the selected data in the script to use it in the html part , is this possible ?!
php part :
<?php
$connect = mysqli_connect("localhost", "root", "", "database");
$result = mysqli_query($connect, "select * from table");
$data = array();
while ($row = mysqli_fetch_array($result)) {
$data[] = $row;
}
print json_encode($data);
?>
script part :
fetch.controller('dbCtrl', ['$scope', '$http', function ($scope, $http) {
$http.get("MY_FILE.php")
.success(function(data){
$scope.data = data;
})
.error(function() {
$scope.data = "error in fetching data";
});
}]);
when i use any of the selected data in the html section nothing appear and stay blank.
any idea ?!