1

Problem:

I am using Google Map API using the link: http://www.phpinsider.com/php/code/GoogleMapAPI/ - and when I try to print out an address on the map manually it will show up but not when selected from a database.

PHP code (this works):

$map->addMarkerByAddress('114 53 Grevgatan 31','The Tudor Arms','<b>The Tudor Arms</b>');

PHP code (this does NOT work):

$location = $row['postalnumber'] . ' ' . $row['address'] . ' ' . $row['city'];
$map->addMarkerByAddress($location , $row['name'],'<b>'. $row['name'] .'</b>');

Desired solution:

To be able to extract data from a table in an SQL database and send it to the Google Map API function.

Additional remarks: When I echo the variables above the address and all information will print out but not when sent to the Google Map API function. Do I need to convert the data into a string?

1 Answer 1

1

Yes, you should say google the format like:

$location = $row['postalnumber'] . ' ' . $row['address'] . ' ' . $row['city'];
$map->addMarkerByAddress("'".$location."'", "'".$row['name']."'","'<b>". $row['name'] ."</b>'");
Sign up to request clarification or add additional context in comments.

1 Comment

Much appreciated, in addition I had to use htmlentities() in PHP because there was a problem with the Swedish characters ÅÄÖ.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.