<?PHP/** Following code would list all the products*///Array for JSON response$response=Array();//include DB Connect classrequire_once__dir__. '/db_connect.php ';//Connecting to DB$db=NewDb_connect ();//get All products from the Products table$result=mysql_query("SELECT * from Fbteam") or die(Mysql_error());#Build GeoJSON Feature collection Array$geojson=Array( ' Type ' = ' featurecollection ', ' features ' =Array());//check for empty resultif(mysql_num_rows($result) > 0) { //looping through all results//Products Node while($row=Mysql_fetch_array($result)) { $feature=Array( ' id ' =$row[' ID '], ' type ' = ' Feature ', ' geometry ' =Array( ' Type ' = ' point ',#Pass Longitude and Latitude Columns here' Coordinates ' =Array($row[' Lon '],$row[' Lat ']) ) ); #Add feature arrays to feature collection array Array_push($geojson[' Features '],$feature); } Header(' Content-type:application/json '); Header("Access-control-allow-origin: *"); EchoJson_encode ($geojson,json_numeric_check);} Else { Echo"No Data";}Mysql_close($con);
PHP request to return data in Geojson format