I have written a android program to store user location info (lat and lon values) to database. This works fine.
What i need to do is “to retrieve those latitude and longitude values from database and mark a route on map”. The following is my part of code which draws map according to the given latitude and longitude values. I found this part of code by surfing net. I dont know how to make it accept data from DB and mark it on map. Please give me idea to do that.
function initialize() {
var latlng = new google.maps.LatLng(18.524220910029783,73.85761860000002);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Here lat and lon values are given directly. I need to retrieve those values from DB instead of giving it directly.
Following is my PHP code to store location information got from android app in to DB
<?php
ob_start();
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="map"; // Table name
$message=$_POST['a'];
$message1=$_POST['b'];
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$query = "INSERT INTO map (id,longitude,latitude) VALUES (DEFAULT,'".$_REQUEST['message']."', '".$_REQUEST['message1']."')";
mysql_query($query) or die(mysql_error("error"));
mysql_close();
?>
Thanks in advance!!
See this will show you how to fetch data from db.This is php task.