Code has been added to clipboard!
Using Both PHP json_decode and json_encode
Example
<?php
header("Content-Type: application/json; charset=UTF-8");
$obj =Â json_decode($_POST["x"], false);
$conn = new mysqli("myServer", "myUser", "myPassword", "Northwind");
$result = $conn->query("SELECT name FROM ".$obj->table." LIMIT ".$obj->limit);
$outp =Â array();
$outp = $result->fetch_all(MYSQLI_ASSOC);
echo json_encode($outp);
?>