将值从php传递到mysql并返回到javascript

时间:2013-08-19 15:38:07

标签: php html mysql google-maps

我正在研究谷歌地图,我试图按颜色对我的标记进行分类。类别表有[id,categoryname,color],而markers表有[id,....,category(类别的表类别的id)]。

在PHP中:

 $result = mysql_query("SELECT * FROM `markers`");

    //Multiple rows are returned
    while ($row = mysql_fetch_array($result, MYSQL_NUM))
    {

        if ( $x == 0 )
        {
             $separator = "";
        }
        else
        {
             $separator = "****";
        }
        //Saving to the String, each variable is separated by three &'s
        $encodedString = $encodedString.$separator.
            "<b><div class='name'></b>".$row[3].
        "</div><div class='opli'><b>Lon:</b> ".$row[2].
        "</div><div class='opli'><b>Lat:</b>".$row[1].
        "</div><div class='opli'><b>Address:</b>".$row[4].
        "</div><div class='opli'><b>Category:</b>".$row[5].
        "</div></div>&&&".$row[1]."&&&".$row[2]."&&&".$row[6]."&&&".$row[5];

        $x = $x + 1;
   $colorgetterq= mysql_query("SELECT color FROM `map`.`category` WHERE id= ".$row[5]."");
   $colorgettert = mysql_fetch_row($colorgetterq);
   $colorgetter= $colorgettert[0];
      } 
Java中的

: colorget = document.getElementById(“colorget”)。value;

    stringArray = encodedString.split("****");

    var x;
    for (x = 0; x < stringArray.length; x = x + 1)
    {
        var addressDetails = [];
        var scale1 = [];
        var marker;
        //Separate each field
        addressDetails = stringArray[x].split("&&&");
        //Load the lat, long data
        var lat = new google.maps.LatLng(addressDetails[1], addressDetails[2]);
        //Create a new marker and info window


        marker = new google.maps.Marker({
            map: map,
            position: lat,
            icon: {                
            strokeWeight: 0.01,
            fillColor: colorget,
            fillOpacity: 0.85,
             path: google.maps.SymbolPath.CIRCLE,
             scale:  5 + addressDetails[3] * (35-5)/(hiscale-loscale),
            },
            content: addressDetails[0]
        });

我不知道我在做什么是错的但是在fillColor中,由于某种原因,颜色仍然是黑色,并且不会加载不同的类别颜色。

1 个答案:

答案 0 :(得分:0)

这里有很多问题,但让我们为你工作。

将此行$colorgetter= $colorgettert[0];替换为$encodedString= $encodedString."&&&" . $colorgettert[0];

此行fillColor: colorget,fillColor: addressDetails[6],