os dejo los 2 codigos:
Formulario:
Código HTML:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Document sans titre</title> </head> <body> <form id="form1" name="form1" method="post" action="amigosok.php"> <p> </p> <p>nombre: <label> <input type="text" name="textfield" /> </label> <label></label> </p> <p>telefono: <input type="text" name="textfield2" /> </p> <p> <label> <input type="submit" name="Submit" value="Enviar" /> </label> </p> <p> </p> <p> </p> </form> </body> </html>
y el codigo de los 2 combos:
Código PHP:
<html>
<head>
</head>
<body>
<?php
$con3 = mysql_connect("localhost","root","");
if (!$con3)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("prueba", $con3);
/*mysql_connect("localhost","root");
mysql_select_db("proveedores");
*/
$re=mysql_query("select * from pais");
if(isset($_POST['pais']))
{
$pais=$_POST['pais'];
$r1=mysql_query("select * from ciudad where idp=".$pais."");
$r2=mysql_query("select nombrep from pais where idp=".$pais."");
$j=mysql_fetch_array($r2);
}
else
{
@$j[nombrep]='seleccione pais';
}
?>
<form id="form1" name="form1" method="post" action="">
<select name="pais" size="1" id="pais" onChange="form1.submit()" style="width:200px">
<option value="0" selected="selected"> <?php echo @$j[nombrep];?></option>
<?php
while($f=mysql_fetch_array($re))
{ echo '<option value='.$f[idp].'>'.$f[nombrep].'</option>';
}
?>
</select>
<select name="ciudad" size="1" id="ciudad" style="width:200px">
<?php
while($f1=mysql_fetch_array($r1))
{ echo '<option>'.$f1[nombrec].'</option>';
}
?>
</select>
<?php
mysql_close($con3);
?>
</form>
</body>
</html>
He buscado por internet y no he encontrado ninguna solucion clara..
Si no habeis entendido algo aqui estoy.
Muchisimas gracias por antelacion.