Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Created September 26, 2012 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wboykinm/3789016 to your computer and use it in GitHub Desktop.
Save wboykinm/3789016 to your computer and use it in GitHub Desktop.
get json from mysql
$geojson = array(
'type' => 'FeatureCollection',
'features' => $feature
);
while($row = mysql_fetch_assoc($dbquery)) {
$feature = array(
'type' => 'Feature',
'geometry' => array(
'type' => 'Point',
'coordinates' => array((float)$row['lon'], (float)$row['lat'])
),
'properties' => array(
'name' => $row['title']
//Other fields here, end without a comma
)
);
array_push($geojson, $feature);
};
mysql_close($connection);
// // Return routing result
header("Content-Type:application/json",true);
echo json_encode($geojson);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment