简体   繁体   English

将数据从SQL转换为PHP中的字符串

[英]Convert data from SQL to string in PHP

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. 我通过以下链接使用Google Map API: http//www.phpinsider.com/php/code/GoogleMapAPI/-当我尝试在地图上手动打印地址时,它将显示,但从数据库。

PHP code (this works): PHP代码(有效):

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

PHP code (this does NOT work): PHP代码(这不起作用):

$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. 为了能够从SQL数据库中的表中提取数据并将其发送到Google Map API函数。

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. 补充说明:当我在地址上方回显变量时,所有信息都会打印出来,但是发送到Google Map API函数时不会打印。 Do I need to convert the data into a string? 我需要将数据转换为字符串吗?

Yes, you should say google the format like: 是的,您应该说Google的格式如下:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM