将 php 结果传递到 html infowindow

发布于 2024-12-18 14:31:16 字数 2047 浏览 0 评论 0原文

大家好,希望一切都好, 这是我的第一篇文章,我对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一笔一画续写前缘 2024-12-25 14:31:16

你可以使用 jQuery 的 get() 函数:

$.get('php_source', function(data) {
    //data variable holds values returned by php script
    //parse and append data to #dialog
});

you can use jQuery's get() function:

$.get('php_source', function(data) {
    //data variable holds values returned by php script
    //parse and append data to #dialog
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文