![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
25/06/2003, 09:23
|
![Avatar de mveraa](http://static.forosdelweb.com/customavatars/avatar29282_1.gif) | | | Fecha de Ingreso: diciembre-2002 Ubicación: santiago-chilito
Mensajes: 1.931
Antigüedad: 22 años, 1 mes Puntos: 2 | |
ojale te sirva este codigo pide tipo de auto(sel0.php) , y en base a este busca en la base de datos en sell1.php despues muestra los resultados(los resultados son en base al primer combo) y los pasa al combo en sel11.php
un saludo.....
sel0.php
<?php
$id=mysql_connect("localhost","root","")or die ("clave fallo");
$conexion=mysql_select_db("base de datos",$id) or die("no se pudo conectar");
$consulta="SELECT DISTINCT TIPO from autos order by TIPO" ;
$res=mysql_query($consulta) or die ("consulta fallo2");
$num=mysql_num_rows($res);
?>
<font size="2"><br>
<br><form action =sel11.php method="post" >
<table width="37%" border="2" height="20"> </font>
<tr>
<td width="25%"><font size="2">TIPO VEHICULO:</font></td>
<td width="75%"><font size="2">
<select name=sfile0 >
<?php
For ($i=0;$i<$num;$i++)
{
$a=mysql_result($res,$i,0);
ECHO "";
echo "<option value=\"".$a."\">".$a;
}
ECHO"</td><BR>";
ECHO "<BR>";
echo "<td width=\"75%\"><input type=submit name=boton2 value=seleccion>";
ECHO "</FORM></td><BR>";
mysql_close();
?>
</select>
</font>
<td>
sel11.php
<?php
$id=mysql_connect("localhost","root","")or die ("clave fallo");
$conexion=mysql_select_db("base de datos",$id) or die("no se pudo conectar");
$consulta="SELECT DISTINCT marca from autos where tipo='".$sfile0."' " ;
$res=mysql_query($consulta) or die ("consulta fallo2");
$num=mysql_num_rows($res);
?>
<br>
<br>
</font>
<form action =sel22.php method="post" >
<table width="37%" border="2" height="20">
<tr>
<td width="25%"><font size="2">TIPO:</font></td>
<td width="75%"><font size="2">
<input name=sfile0 value="<?php echo $sfile0 ?>">
</font></td>
<BR>
</tr>
<tr>
<td width="25%"><font size="2">MARCA:</font></td>
<td width="75%"><font size="2">
<select name=sfile >
<?php
For ($i=0;$i<$num;$i++)
{
$a=mysql_result($res,$i,0);
ECHO "";
echo "<option value=\"".$a."\">".$a;
}
ECHO"</td><BR>";
ECHO "<BR>";
echo "<td width=\"75%\"><input type=submit name=boton2 value=seleccion>";
ECHO "</FORM></td><BR>";
mysql_close();
?>
</select>
</font>
</table>
</form>
</div>
</div>
</div> |