Skip to content

Instantly share code, notes, and snippets.

@geoluther
Last active November 24, 2016 06:33
Show Gist options
  • Save geoluther/f2e2538c1379055a18df663e87fa9d0e to your computer and use it in GitHub Desktop.
Save geoluther/f2e2538c1379055a18df663e87fa9d0e to your computer and use it in GitHub Desktop.
$json = array();
$result = mysqli_query ($connection, $query);
while($row = mysqli_fetch_array ($result))
{
$data = array(
'field1' => $row['field1'],
'field2' => $row['field2']
);
array_push($json, $data);
}
$jsonstring = json_encode($json);
echo $jsonstring;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment