Ver Mensaje Individual
  #2 (permalink)  
Antiguo 22/07/2010, 18:50
Avatar de dcreate
dcreate
 
Fecha de Ingreso: octubre-2009
Ubicación: Veracruz
Mensajes: 536
Antigüedad: 14 años, 7 meses
Puntos: 22
Respuesta: Consulta sobre como hacer y grabar con un select

se me ocurre algo como:

index.php
Código PHP:
<?php
//hacer coneccion de bd
$bus=mysql_query("select *from nivel");
?>
<form action="consulta.php" method="post">
Nivel: <select name="nivel">
<option value="0">Elige..</option>
<?php
while($con=mysql_fetch_array($bus))
{
echo 
'<option value="'.$con['id'].'">'.$con['descripcion'].'</option>';
}
echo 
'</select>';
?>
<input type="submit" name="enviar" value="enviar">
/form>
consulta.php

Código PHP:
<?php
//hacer conexion de bd
$nivel=$_POST['nivel'];
$bus=mysql_query("select *from roles where id_nivel='$nivel'");
$con=mysql_fetch_array($bus);
$fila=mysql_num_rows($bus);
if(
$fila>0){
?>
<form action="proc.php" method="post">
Nivel:<input type="text" name="nivel" value="<?php echo $con['id_nivel']?>">
Descripcion:<input type="text" name="descripcion" value="<?php echo $con['descripcion']?>">
Rol: <input type="text" name="rol" value="<?php echo $con['roles']?>">
<input type="submit" value="enviar">
</form>
<?php
}
else
{
echo 
'<script>alert("NO existe dato"); history.back();</script>';
}
?>
__________________
Somos lo que pensamos, como pensamos vivimos.