将 php 结果传递到 html infowindow
大家好,希望一切都好, 这是我的第一篇文章,我对 php 和 html 非常陌生。我必须使用 Gmap 来处理 GIS,我有一些代码,在 php 代码中我正在访问数据库并检索结果 $rows 我想在 infowindow 中显示的那些行元素下拉输入,单击地图时会出现信息窗口,请建议执行此操作的方法。如果我得到一些这样的例子那就太好了..
<?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>')};
Hello everyone hope all are doing good,
This is my first post and I am very new to php and html.I have got to work on GIS using Gmap i have some code where in php code I am accesing db and retriving result $rows those row elements I want to display in infowindow dropdown input,infowindow apeares when click on map please suggest methods to do this. if I get some examples of this kind that will be great..
<?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);
?>
Below is infowindow code where I want to add dropdown with result of php
inplace of options I am hard coding here now
$(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>')};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以使用 jQuery 的
get()
函数:you can use jQuery's
get()
function: