I must be missing something... because I'm really a noob at this.
I have this angularjs data:
$scope.todoList = [
{ text: 'Check me out' },
{ text: 'Lorem ipsum dolor sit amet, possit denique oportere at his, etiam corpora deseruisse te pro' },
{ text: 'Ex has semper alterum, expetenda dignissim' },
];
And I wanted to put it in a mysql table instead. I created the table and then tried to get table data:
JS:
$http({method:'POST',url:'process.php'})
.then(
function successCallback(response) { $scope.todoList = response.data;},
function errorCallback(response) {$scope.todoList = "ERROR!";});
PHP:
$sql = "SELECT * from `todolist`";
$result = $conn->query($sql);
$data = array();
while ($row = mysqli_fetch_assoc($result)) {
$data[] = array("text" => $row['text']);
}
echo json_encode($data);
When I manually try the PHP the output is:
[{"text":"Check me out"},{"text":"Lorem ipsum dolor sit amet, possit denique oportere at his, etiam corpora deseruisse te pro"},{"text":"Ex has semper alterum, expetenda dignissim"}]
Does someone know where the problem is?