从数据库更改谷歌地图标记图像

Is there any way to do this?

Like, i have some data in my DB, and i show this data as markers in googlemap api.

but i want to change the marker image, from the same ID from my DB.

the name and the description, is showing correctly marker by marker, but i want to change the marker image

my code:

  <html>
 <head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
 <title></title>
 <link rel="stylesheet" type="text/css" href="style.css">
 <script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>
 <script type="text/javascript">


 var icon = new google.maps.MarkerImage('http://localhost/partytime/uploadedimages/davi.png',
 new google.maps.Size(50,50), 
 new google.maps.Point(0,0),
 new google.maps.Point(0,0),
 new google.maps.Size(50,50));
 var center = null;
 var map = null;
 var currentPopup;
 var bounds = new google.maps.LatLngBounds();
 function addMarker(lat, lng, info) {
 var pt = new google.maps.LatLng(lat, lng);
 bounds.extend(pt);
 var marker = new google.maps.Marker({
 position: pt,
 icon: icon,
 map: map
 });
 var popup = new google.maps.InfoWindow({
 content: info
 //maxWidth: 300

 });
 google.maps.event.addListener(marker, "click", function() {
 if (currentPopup != null) {
 currentPopup.close();
 currentPopup = null;
 }
 popup.open(map, marker);
 currentPopup = popup;
 });
 google.maps.event.addListener(popup, "closeclick", function() {
 map.panTo(center);
 currentPopup = null;
 });
 }
 function initMap() {
 map = new google.maps.Map(document.getElementById("map"), {
 center: new google.maps.LatLng(0, 0),
 zoom: 3,
 mapTypeId: google.maps.MapTypeId.ROADMAP,
 mapTypeControl: false,
 mapTypeControlOptions: {
 style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
 },
 navigationControl: true,
 navigationControlOptions: {
 style: google.maps.NavigationControlStyle.SMALL
 }
 });
 <?php
 }
 $query = mysql_query("SELECT * FROM localizacoes");
 while ($row = mysql_fetch_array($query)){
 $r =  explode( ',', $row['posicao'] );
 $name=$row['nome'];
 $lat = $r[0];
 $lon = $r[1];

 $dataevento = explode( '-', $row['dataevento'] );
 $ano = $dataevento[0];
 $mes = $dataevento[1];
 $dia = $dataevento[2];

 echo ("addMarker($lat, $lon,'<h1><b>$name</b></h1>$dia-$mes-$ano');
");
 }
 ?>    

 }
 </script>
 </head>
 <body onload="initMap()" style="margin:0px; border:0px; padding:0px;">
 <div id="centro">
 <div id="map">

 </div>
 </div>
 </html>

Note: in this code, i put a imagem from localhost...this imagem refers an ID, and i want to show each image from each id as googlemap marker icon

See this article: Using PHP/MySQL with Google Maps: Custom Icons for information about how to associate marker icons with a type field from your database.

From that article:

Custom Icons

You can specify custom icons for your markers.

Start by creating an associative array which associates your icons to your type strings: 'restaurant' or 'bar.' This makes the icons easy to reference later when you create markers from the XML.

var customIcons = {
  restaurant: {
    icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png'
  },
  bar: {
    icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png'
  }
};