Ver Mensaje Individual
  #8 (permalink)  
Antiguo 21/03/2003, 07:37
mauro28
 
Fecha de Ingreso: noviembre-2002
Mensajes: 53
Antigüedad: 21 años, 5 meses
Puntos: 0
CODIGO

<?
$conexion = mysql_connect($servidor, $usuario, $clave) or die(mysql_error());
mysql_select_db($basedatos, $conexion) or die(mysql_error());

echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">\n\n";
echo "<select name=\"id_padre\" onChange=\"this.form.submit()\">\n";


echo "<option value=\"\"> Seleccione </option>\n";


$SQLconsulta_padre="SELECT * FROM tabla_padre";
$consulta_padre = mysql_query($SQLconsulta_padre,$conexion) or die(mysql_error());

if (mysql_num_rows($consulta_padre) != 0)

{
While ($registro_padre=mysql_fetch_assoc($consulta_padre ))
{

echo "<option value=\"".$registro_padre['id']."\">".$registro_padre['item_texto']."</option>\n";

}


}
else
{
echo "<option value=\"\"> No hay registros en la tabla padre </option>";
}
echo "</select>\n\n";


mysql_free_result($consulta_padre);

echo "<select name=\"id_hija\">\n";
if (!empty($id_padre))
{
$SQLconsulta_hija="SELECT * FROM tabla_hija WHERE id_padre=$id_padre";
$consulta_hija = mysql_query($SQLconsulta_hija,$conexion) or die(mysql_error());

if (mysql_num_rows($consulta_hija) != 0)
{
While ($registro_hija=mysql_fetch_assoc($consulta_hija))
{
echo "<option value=\"".$registro_hija['id']."\">".$registro_hija['item_texto']."</option>\n";
}
}
else
{
echo "<option value=\"\"> No hay registros </option>";
}
}
else
{
echo "<option value=\"\"> Seleccione algo </option>";
}
mysql_free_result($consulta_hija);



?>


<br><br><br>
<input type="submit" name="Submit" value="Enviar datos" />