I am creating simple request for GET a "message" with title etc from MySQL server.
So, I've got something like this in my AngularJS:
$http({
url: 'http://localhost/webpack/downloadMessage.php',
method: 'GET',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(function(response){
console.log("CHECKED");
console.log(response.data);
}, function(response) {
alert('something wrong');
})
})
}
Just a request for data. But I'm confused with my php code, because I'm a beginner, can you help me what's wrong? I want just whole table where section = 3.
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
if(!isset($_POST)) die();
session_start();
$response = [];
$con = mysqli_connect('localhost', 'root', '', 'projekt');
$query = "SELECT * FROM messages WHERE section='3'";
$result = mysqli_query($con, $query);
echo json_encode($result);
It's without errors, but in my console i've got this:
CHECKED {current_field: null, field_count: null, lengths: null, num_rows: null, type: null}
mysqli_querydoes not return result you expect.fetch_functions do it.