PHP request to return data in Geojson format

Source: Internet
Author: User
Tags db connect

<?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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.