Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/05/2010, 19:51
marcinf2
 
Fecha de Ingreso: enero-2002
Ubicación: Lima
Mensajes: 461
Antigüedad: 22 años, 3 meses
Puntos: 1
no funciona el codigo cuando envio variables

la verdad no se si va aqui este post o en javascript


tengo un buscador que contiene 3 selects(tipo,operacion, localidad) y envia mediante post a otro archivo php que contiene un codigo en javascript que recoge esas 3 variables y las ubica en un mapa de google.

a su vez dentro del codigo javascript lee un archivo xml generado mediante php que recoje todos los datos de una BD mysql tengo que filtrar esas 3 variables dentro del select pero no sale en el mapa..

este es el buscador
Código HTML:
<form action="search_mapa.php" method="post">
<select name="tipo" id="tipo">
                      <option value="emprendimientos">Emprendimientos</option>
                      <option value="casa">Casas</option>
                      <option value="departamento">Departamentos</option>
                      <option value="locales">Locales/Oficinas</option>
                      <option value="terrenos">Terrenos</option>
                    </select>

<select name="operacion" id="operacion">
                        <option>Seleccionar</option>
                        <option value="venta">venta</option>
                        <option value="alquiler">Alquiler</option>
                      </select>
<select name="localidad" id="localidad">
                        <option>Seleccionar</option>
                        <option value="san isidro">san isidro</option>
                        <option value="avellaneda">avellaneda</option>
                        <option value="lanus">lanus</option>
                        <option value="ituzaingo">ituzaingo</option>
                      </select>
<input type=image src="imagenes/buscar_bt.jpg" width="84" height="25"> 
este es el archivo que me genera el xml con los datos guardados en base de datos
phpsqlajax_genxml.php
Código PHP:
<?php
require("xml/phpsqlajax_dbinfo.php");
// recojo variables de formulario
$tipo=$_POST['tipo'];
$operacion=$_POST['operacion'];
$distrito=$_POST['localidad'];
function 
parseToXML($htmlStr

$xmlStr=str_replace('<','&lt;',$htmlStr); 
$xmlStr=str_replace('>','&gt;',$xmlStr); 
$xmlStr=str_replace('"','&quot;',$xmlStr); 
$xmlStr=str_replace("'",''',$xmlStr); 
$xmlStr=str_replace("&",'
&amp;',$xmlStr); 
return $xmlStr; 


// Opens a connection to a MySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
  die('
Not connected ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('
Can't use db : ' mysql_error());
}

// Select all the rows in the markers table
$query "SELECT * FROM inmobiliario WHERE tipo='$tipo' AND operacion='$operacion' AND localidad='$localidad";
$result mysql_query($query);
if (!
$result) {
  die(
'Invalid query: ' mysql_error());
}

header("Content-type: text/xml");

// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  
// ADD TO XML DOCUMENT NODE
  
echo '<marker ';
  echo 
'id="' parseToXML($row['id']) . '" ';
  echo 
'tipo="' parseToXML($row['tipo']) . '" ';
  echo 
'titulo="' parseToXML($row['titulo']) . '" ';
  echo 
'operacion="' parseToXML($row['operacion']) . '" ';
  echo 
'direccion="' parseToXML($row['direccion']) . '" ';
  echo 
'localidad="' parseToXML($row['localidad']) . '" ';
  echo 
'precio="' parseToXML($row['precio']) . '" ';
  echo 
'lat="' $row['lat'] . '" ';
  echo 
'lng="' $row['lng'] . '" ';
  echo 
'/>';
}

// End XML file
echo '</markers>';

?>
probe enviando las 3 variables y hasta aqui el xml me lo genera bien
el problema pasa aqui en el codigo javascript

este es donde esta el codigo javascript que me genera el mapa
search_mapa.php
Código:
function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(-12.043333,-77.028333), 13);

        GDownloadUrl("http://localhost/phpsqlajax_genxml.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
			var id = markers[i].getAttribute("id");
			var tipo = markers[i].getAttribute("tipo");
            var titulo = markers[i].getAttribute("titulo");
            var operacion = markers[i].getAttribute("operacion");
			var precio = markers[i].getAttribute("precio");
			var direccion = markers[i].getAttribute("direccion");
			var distrito = markers[i].getAttribute("distrito");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
            var marker = createMarker(point, id, tipo, titulo, operacion,precio,direccion,distrito);
            map.addOverlay(marker);
          }
        });
      }
    }

    function createMarker(point, id, tipo, titulo, operacion,precio,direccion,distrito) {
      var marker = new GMarker(point, customIcons[tipo]);
      var html = "<b>" + titulo + "</b> <br/>" + operacion +"<br/>"+ precio+"<br/><a href=ver.php?id="+id+">ver detalles</a>" ;
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }
aqui enviando esas variables me tendria que mostrar el mapa filtrado pero no muestra nada

no funciona cuando las envio por el buscador
__________________
Marcelo Acampora
mi pagina web personal
www.destinitytravel.com