Created
September 26, 2012 16:29
-
-
Save wboykinm/3789016 to your computer and use it in GitHub Desktop.
get json from mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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