Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/01/2010, 14:21
cpozo
 
Fecha de Ingreso: septiembre-2007
Mensajes: 29
Antigüedad: 17 años, 6 meses
Puntos: 0
Pasar el valor de un select a otra página

Hola,

Tengo una primera página donde tengo un select y unos checkbox y quiero llevar esos valores a otra pagina. Con los valores de los checkbox, no hay problema, pero no consigo obtener el valor seleccionado del select. A ver si alguien me puede echar una mano.

El código del primer fichero:
Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Documento sin t&iacute;tulo</title>
  6. </head>
  7.  
  8. <body>
  9. <?
  10. include ("conexion.php");
  11.  
  12. $resultado=mysql_query("SELECT * FROM jos_users");
  13.  
  14. // Se inicial el formulario
  15. //echo "<form action=\"procesar.php\" method=\"post\"> \n";
  16. ?>
  17. <form name="form1" action="procesar.php" method="post">
  18.  
  19. <SELECT NAME="listaEventos" SIZE=1">
  20.      
  21.    <?
  22.    
  23.     $query=mysql_query("SELECT titulo FROM jos_eventos_competicion");
  24.    while ($row=mysql_fetch_array($query))
  25.    {
  26.    ?>
  27.    <OPTION VALUE="<?php echo $row['id'] ?>"> <?php echo $row['titulo'] ?></OPTION>
  28.    
  29.    <? } ?>
  30. </SELECT>
  31.  
  32.  
  33. <?
  34.  
  35. // Extraemos y componemos los checbox dinámicos de los datos de nuestra tabla de la BD.
  36. while ($row = mysql_fetch_array($resultado)){
  37.   echo "<input type=\"checkbox\" name=\"seleccion[]\" value=\"".$row['id']."\">".$row['name']."<br>";
  38. }
  39.  
  40. // Cerramos el formulario y ponemos nuestro botón de Submit.
  41. echo "<input type=\"submit\" name=\"Submit\" value=\"Enviar\">";
  42. //echo "</form>";
  43. ?>
  44. </form>
  45. </body>
  46. </html>

y el código del otro fichero: procesar.php

Código PHP:
Ver original
  1. <?
  2. include ("conexion.php");
  3. $lista=implode(',',$_POST['seleccion']);
  4. $listaEv= $_POST['listaEventos'];
  5. echo $listaEv[0];
  6. echo"$listaEv";  
  7. $sql=mysql_query("Select name FROM jos_users WHERE id IN(".$lista.")", $enlace);
  8. while ($row=mysql_fetch_array($sql)){
  9. echo $row["name"].'<br><input type=\"text\" value="" name=\"$row["name"]\"><br>';
  10. }
  11. ?>
Gracias.