2012-12-11 38 views
1

我有这个代码在谷歌地图在我的网页..我想改变经度和纬度的值..它应该从我的数据库..我将如何实现它?使用zend框架将数据从数据库传递给jquery

$(function() { 
    demo.add(function() { 
     $('#gmap').gmap({'center': '47.660937,9.569803', 'zoom': 10,'disableDefaultUI':true, 'callback': function() { 
      var self = this; 
      self.addMarker({'position': this.get('map').getCenter() }).click(function() {});  
        }}); 
    }).load(); 
}); 

这里的时候,我怎么申报从数据库中我的变量..

$propertyId = $this->_getParam('propertyId', null); 

      $propDetail = $propertyDb->getProperty($sessionOutlet, $propertyId); 

      $this->view->description = $propDetail[0]['Description']; 
      $this->view->propertyname = $propDetail[0]['PropertyName']; 
      $this->view->longitude = $propDetail[0]['Longitude']; 
      $this->view->latitude = $propDetail[0]['Latitude']; 

回答

0

关于从ZEND JS的变量声明,你可以将PHP变量在JS代码:

var longitude = <?php echo $this->longitude; ?>; // for number 
var description = "<?php echo $this->description; ?>"; // for string 

您也可以使用内联条件:

var myVar = "<?php echo (isset($this->myVar)) ? $this->myVar : 'Not defined' ; ?>"