Я пытаюсь получить данные базы данных MYSQL на AngularJS, Данные на хинди.Для параметров сортировки базы данных установлено значение utf8_unicode_ci.
<div ng-controller="postController" ng-init="display_data()">
<table class="table table-bordered">
<tr>
<th>Post id </th>
<th>Post Title</th>
<th>Post Details</th>
<th>Post Status</th>
</tr>
<tr ng-repeat="x in posts" >
<td>{{x.postId}}</td>
<td>{{x.postTitle}}</td>
<td>{{x.postDetails}}</td>
<td>{{x.postStatus}}</td>
</tr>
</table>
</div>
<script>
var app = angular.module("concept", []);
app.controller("postController", function ($scope, $http) {
$scope.display_data = function () {
$http({
method: 'GET',
url: 'getPost.php'
}).then(function (post) {
$scope.posts = post.data;
}, function (error) {
alert("Something went wrong!!");
});
}
});
</script>
Нет ошибок в консоли
Вот код php:
<?php
header('Content-Type: text/html; charset=utf-8');
$conn = mysqli_connect("localhost","root","","concept") or die(mysqli_error()) ;
$output = array();
$query = "SELECT * FROM userpost";
$result=mysqli_query($conn,$query);
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_array($result))
{
$output[] = $row;
}
echo json_encode($output);
}
?>
код работает на локальном сервере.