Below is the entire code block, this script is being called via a REST service in a mobile app which then maps the json returned into a select list. It works perfectly. and returns JSON in the below format.
So I need to insert the placeholder so it ends up in the same format, and at the beginning.
{
"list": [
{
"column2": "Ajoblanco con Uvas (Garlic Soup with Grapes)",
"column1": 86127
},
{
"column2": "All-American Meat Loaf",
"column1": 86128
},
{
"column2": "All-American Meat Loaf",
"column1": 86018
}
}
Code: Select all
include_once("../../dbvars.php");
try {
$con = new PDO("pgsql:user=$dbuser dbname=$dbrecipes password=$dbpass");
}
catch(PDOException $e) {
$response["message"] = $e->getMessage();
exit;
}
$user=$_GET['user'];
$rsuid=$con->query("SELECT id from owner where owner='$user'");
foreach ($rsuid as $row) {
$uid = $row['id'];
}
$list = $con->query("SELECT * FROM query_owner_recipes_with_name_id($uid)")->fetchAll(PDO::FETCH_ASSOC);
$response['list'] = $list;
echo json_encode($response);