Code has been added to clipboard!

Basic Use of PHP json_decode and json_encode

Example
<?php
header("Content-Type: application/json; charset=UTF-8");
$obj = json_decode($_GET["x"], false);

$connect = new mysqli("RequiredServer", "RequiredUsername", "RequiredPassword", "Northwind");
$result = $connect->query("SELECT name FROM ".$obj->table." LIMIT ".$obj->limit);
$output = array();
$output = $result->fetch_all(MYSQLI_ASSOC);

echo json_encode($output);
?>