Setting javascript file and its line:
center: new google.maps.LatLng(<?=$lat?>, <?=$lng?>),
Geo coder and pull data from database:
// get address from database
mysql_connect('host', 'user', 'pass');
mysql_select_db('dbname');
$address=str_replace(" ","+",$address);
$url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".
$address."&sensor=false";
# INITIATE CURL.
$curl = curl_init();
# CURL SETTINGS.
curl_setopt($curl, CURLOPT_URL,"$url");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
# GRAB THE XML FILE.
$result = curl_exec($curl);
curl_close($curl);
# SET UP XML OBJECT.
$xml = new SimpleXMLElement($result);
$flag=0;
foreach ($xml->result->geometry as $item){
if($flag==0){
$lat=$item->location->lat;
$lng=$item->location->lng;
$flag=1;
}
}
setcookie("lat",$lat, time()+3600*24);
setcookie("lng",$lng, time()+3600*24);
header("location: index20.php");
?>
Can be improved this PHP code?