mmm no me acuerdo bien como lo hacie pero algo asi es
lee de la bd llena el primer selec despues en base a ese vuelve a llamar en la bd y muestra en el otro select
http://www.ahumadagarcia.cl/ayg/busca1.php ahi esta funcionando
si no lo entiendes me mandas un correo
IF ($BOTON=="BUSCAR VENTAS PROPIEDADES")
{
$id=mysql_connect("localhost","","")or die ("clave fallo");
$conexion=mysql_select_db("",$id) or die("no se pudo conectar");
$consulta="SELECT DISTINCT tipo from propiedades where odalidad='VENTA' order by tipo " ;
$res=mysql_query($consulta) or die ("consulta fallo2");
$num=mysql_num_rows($res);
IF ($sfile0=="")
{
$sfile0=mysql_result($res,0,0);
$ahora=0;
}
else
{
$ahora=1;
}
?>
<table width="65%" border="0">
<form name="form1" method="post" action="">
<tr>
<td><em><strong><font size="2">TIPO DE PROPIEDAD: </font></strong> </em></td>
<td>
<select name="sfile0" >*
<?php
echo "<option value=\"".$sfile0."\">".$sfile0."</option>";
For ($i=0;$i<$num;$i++)
{
$a=mysql_result($res,$i,0);
if ($sfile0<>$a)
{
echo "<option value=\"".$a."\">".$a;
}
}
mysql_close();
?>
</select>
<input type="submit" name="Submit" value="BUSCAR"></td>
</form> </tr>
<tr>
<td> </td>
<td>
<form name="form2" method="post" action="resultados_basicos.php">
<input type=hidden name=sfile0 value="<?php ECHO $sfile0; ?>">
<input type="submit" name="BOTON4" value="VER TODOS LAS VENTAS DE <?php ECHO $sfile0; ?>">
</form></td> </tr>
<?php
$id=mysql_connect("localhost","a","")or die ("clave fallo");
$conexion=mysql_select_db("",$id) or die("no se pudo conectar");
$consulta="SELECT DISTINCT comuna from propiedades where modalidad='venta' and tipo='".$sfile0."'" ;
$res=mysql_query($consulta) or die ("consulta fallo3");
$num=mysql_num_rows($res);
?>
<tr>
<form name="form3" method="post" action="/ayg/resultados_basicos.php">
<td>
<p><strong><em><font size="2">COMUNA:</font></em></strong> </td>
<td> <select name="sfile1" <?php
if ($ahora==0)
{ echo "DISABLED";
}
?>>
<?php
For ($i=0;$i<$num;$i++)
{
if ($ahora==1)
{
$b=mysql_result($res,$i,0);
}
echo "<option value=\"".$b."\">".$b;
}
mysql_close();
?>
<input type=hidden name=sfile0 value="<?php ECHO $sfile0; ?>">
</select>
<input type="submit" name="BOTON1" value="VENTA" <?php
if ($ahora==0)
{ echo "DISABLED";
}
?>>
</form></td>
<?php
}
?>
o pones la bd en un archivo aparte y haces un include ahora que lo veo creo que queda mejor asi. hace mucho tiempo que no veia este codigo que hice.
chao.....