Ver Mensaje Individual
  #6 (permalink)  
Antiguo 31/08/2011, 13:01
calixhh01
 
Fecha de Ingreso: abril-2011
Ubicación: Cix
Mensajes: 9
Antigüedad: 13 años
Puntos: 0
Respuesta: obtener valor de <select para php

Hola solucione el problema. El codigo es el siguiente:

<h1>Seleccione los datos para la matricula del producto</h1>
<hr>
<?php
require("class.php");
$sql1 = "SELECT * FROM LIBROS";
$sql2 = "SELECT * FROM EDITORIALES";
$res1 = $cnx->query($sql1) or die ($cnx->error);
$res2 = $cnx->query($sql2) or die ($cnx->error);
$var1 = $_POST['id_libros'];
$var2 = $_POST['id_editoriales'];

?>

<form action="matricula.php" method="POST">
<select name="id_libros">
<option>[Seleccione un nombre de libro]</option>
<?php
while($reg = $res1->fetch_object()){
echo "<option value='".$reg->id_libros."'>".$reg->nombre_libro."</option>";
}mysql_close($cnx)?>?>
</select>
<input type="submit" value="Grabar">
</form>


<form action="matricula.php" method="POST">
<select name="id_editoriales">
<option>[Seleccione un nombre del editorial]</option>
<?php
while($reg = $res2->fetch_object()){
echo "<option value='".$reg->id_editoriales."'>".$reg->nombre_editorial."</option>";
} mysql_close($cnx)?>
</select>
<input type="submit" value="Grabar">
</form>


<table width="200" border="1" align="center">
<tr>
<td>Id de Libro</td>
<td>Id de editorial</td>
<td>Libro</td>
<td>Editorial</td>
</tr>
<tr>
<td><?php echo $var1;?></td>
<td><?php echo $var2?></td>
<td></td>
<td></td>
</tr>
</table>
<a href="registro_libros.php">Ir a registrar libros</a>
<a href="registro_editorial.php">Ir a registrar editorial</a>