大家好,希望一切顺利, 这是我的第一篇文章,我是php和html的新手。我必须使用Gmap进行GIS工作我有一些代码,我在PHP代码中访问数据库并检索结果$ rows我要在infowindow中显示的那些行元素下拉输入,infowindow apeares点击地图时请建议执行此操作的方法。如果我得到一些这样的例子会很棒......
<?php
$serverName = "localhost\SQLEXPRESS"; $connectionInfo = array
( "Database"=>"master", "UID"=>"sa", "PWD"=>"sa");
$conn = sqlsrv_connect( $serverName, $connectionInfo );
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$sql = "SELECT Group_ID FROM Test where configured =1";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) { //Here in $ row i get result which i want to display as dropdown in below html
/// echo $row['Group_ID']."<br />";
}
sqlsrv_free_stmt( $stmt);
?>
下面是infowindow代码,我想添加带有php结果的下拉列表 替换选项我现在很难编码
$(map).click( function(event) {
$('#map_canvas').gmap('addMarker', {'position': event.latLng, 'draggable':
true, 'bounds': false}, function(map, marker) {
$('#dialog').append('<form id="dialog'+marker.__gm_id+'" method="get" action="/" style="display:none;"><p><label for="country">Country</label><input id="country'+marker.__gm_id+'" class="txt" name="country" value=""/></p><p><label for="state">State</label><input id="state'+marker.__gm_id+'" class="txt" name="state" value=""/></p><p><label for="address">Address</label><input id="address'+marker.__gm_id+'" class="txt" name="address" value=""/></p><p><label for="Group">Group</label><select><option value="G4">Group4</option><option value="G1">Group1</option><option value="G2">Group2</option><option value="G3">Group3</option></select></p><p><label for="test">Comment</label>'<?php echo ($row); ?>'</p></form>')};
答案 0 :(得分:0)
你可以使用jQuery的get()
函数:
$.get('php_source', function(data) {
//data variable holds values returned by php script
//parse and append data to #dialog
});