Невозможно выбрать данные из базы данных
//angularjs_DB.php
<?php
\t $con=mysqli_connect("localhost","root","","hris_iit");
\t // Check connection
\t if (mysqli_connect_errno())
\t {
\t \t echo "Failed to connect to MySQL: " . mysqli_connect_error();
\t }
\t $sql="SELECT idemployee, current_designation,current_salary,previous_designation,previous_salary,reason,effective_date from promotion";
\t $result = $con->query($sql);
\t
// output data of each row
\t $output="[";
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
\t \t if($output!="["){$output .=",";}
\t \t $output .='{"idemployee":"' .$row["idemployee"] .'",';
\t \t $output .='"current_designation":"' .$row["current_designation"] .'",';
\t \t $output .='"current_salary":"' .$row["current_salary"] .'",';
\t \t $output .='"previous_designation":"' .$row["previous_designation"] .'"}';
//echo "<br> id: ". $row['idemployee']. $row['current_designation']. $row['current_salary']. $row['previous_designation'];
\t \t
\t }
\t $output .="]";
\t mysqli_close($con);
\t
\t echo ($output);
\t //return ($output);
?>
<!DOCTYPE html>
<html>
<head>
\t <script src="angular.min.js">
\t </script>
</head>
<body>
\t
\t <div data-ng-app="" data-ng-controller="customerController">
\t \t <table>
\t \t \t <tr>
\t \t \t \t <td><b>idemployee</b></td>
\t \t \t \t <td><b>current_designation</b></td>
\t \t \t \t <td><b>current_salary</b></td>
\t \t \t \t <td><b>previous_designation</b></td>
\t \t \t </tr>
\t \t \t <tr data-ng-repeat="x in names">
\t \t \t \t <td>{{x.idemployee}}</td>
\t \t \t \t <td>{{x.current_designation}}</td>
\t \t \t \t <td>{{x.current_salary}}</td>
\t \t \t \t <td>{{x.previous_designation}}</td>
\t \t \t </tr>
\t \t </table>
\t </div>
\t
\t <script>
\t \t function customerController($scope,$http){
\t \t \t $http.get("http://localhost/startup/angularjs_DB.php")
\t \t \t .success(function(response){$scope.names=response;});
\t \t
\t \t }
\t </script>
\t <!-- The code above can also be used to fetch data from a database -->
</body>
<html>
Problem in output of the html code that are not values from Database !!! Output likes following: idemployee current_designation current_salary previous_designation {{x.idemployee}} {{x.current_designation}} {{x.current_salary}} {{x.previous_designation}}
Можете ли вы отправить мне то, что он показывает – vamsikrishnamannem
На самом деле ошибка не возникает. Но не может получить значения из базы данных с помощью данного кода html –
вы можете включить json, созданный вашим php? Я не PHP, но я бы предложил захватить массив из базы данных и сериализовать это, чтобы JSON был «лучше». Я предполагаю, что JSON недопустим, и Angular не может его использовать. Вы видите ошибки в консоли браузера? –