Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

How To Develop Own PHP API

Share this post!
 Vote this!


First thing, you need to have a database in place with data.


//get a connection to mysql

$con = mysql_connect("localhost","root","root") or die("could not connect".mysql_error());

//select your database table

mysql_select_db("android_maps", $con) or die("Could not select database".mysql_error());

//get your results with a mysql query

$result = mysql_query("SELECT gmaps.*, urls.* FROM gmaps, urls WHERE urls.idgmaps = gmaps.idgmaps") or die(mysql_error());

//run a while loop get your data.

while($place = mysql_fetch_array($result, MYSQL_ASSOC)) {

$places[] = array('location'=>$place);

}

$output = json_encode(array('map' => $places));

echo $output;

mysql_close($con);

}

More... 

0 comments:

Post a Comment