I'm coding a php server sending arrays response using JSON. Now i simply testing the php code but the result is empty:
{"routes":[]}
There is my code in PHP:
<?php
require_once 'connect.php';
if ($_SERVER['REQUEST_METHOD'] =='POST') {
$region = $_POST['region'];
$sql = "SELECT * FROM routes WHERE region='$region'";
$result = mysqli_query($conn, $sql);
$dbdata = array();
while ($row = $result->fetch_assoc()) {
$dbdata[] = $row;
}
$obj = (object)[
'routes' => $dbdata
];
echo json_encode($obj, JSON_UNESCAPED_SLASHES);
}
?>
I'am testing in postman, sending POST:
http://MY PATH/filter.php?"region"=West