Tema: ciego
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/10/2013, 06:46
jegggf
 
Fecha de Ingreso: septiembre-2012
Ubicación: montevideo
Mensajes: 131
Antigüedad: 11 años, 7 meses
Puntos: 0
Pregunta ciego

buenas necesito agregarle un name a un select,pero no puedo hacerlo dentro de un while:
Código PHP:
Ver original
  1. <?php
  2.      
  3.     include("conecta.php");
  4.      
  5.      global $db_selected;
  6.      global $db;
  7.      //$usertable = 'prueba1';
  8.      
  9.     $result = mysql_query("SELECT objetos FROM prueba1", $db);
  10.      
  11.     echo "<select > \n"; //name= "objetos[]"
  12.      
  13.     while ($row = mysql_fetch_row($result)){
  14.            echo "<option value="$row[0]"></option> ";
  15.     }
  16.     echo "</select> \n";
  17.      
  18.       $result1 = mysql_query("SELECT lugares FROM prueba2", $db);
  19.      
  20.     echo "<select > \n"; //name="lugares[]"
  21.      
  22.     while ($row = mysql_fetch_row($result1)){
  23.            echo "<option>$row[0]</option> ";
  24.     }
  25.     echo "</select> \n";  
  26.          
  27.     ?>

esto funciona, pero al tomarlo con el siguiente codigo no lo ve, agradezco respuesta.

Código PHP:
Ver original
  1. <html>
  2.     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3.     <html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">
  4.      <head>
  5.      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6.      
  7.      
  8.      
  9.       <title> prueba3 </title>
  10.      </head>
  11.      
  12.      
  13.       <body>
  14.      
  15.         <p align=center>Asignacion</p>
  16.        
  17.         <br><br>
  18.        
  19.        
  20.         <form method="post" action="adjudicar3.php" name= "formulario" >
  21.         <p> objetos   lugares </p>
  22.     <?php
  23.      
  24.     include("conecta.php");
  25.      
  26.      global $db_selected;
  27.      global $db;
  28.      
  29.      
  30.      
  31.     //echo "<select > \n"; //name= "objetos[]"
  32.     function obj($result){
  33.      
  34.     $result = mysql_query("SELECT objetos FROM prueba1", $db);
  35.        while ($row = mysql_fetch_row($result))
  36.        {
  37.            echo "<option>$row[0]</option> ";
  38.        }
  39.                          }
  40.     //echo "</select> \n";
  41.      ?><select name="objetos" value="<?php obj($result); ?>"></select>
  42.      <?php
  43.       $result1 = mysql_query("SELECT lugares FROM prueba2", $db);
  44.      
  45.     echo "<select > \n"; //name="lugares[]"
  46.      
  47.     while ($row = mysql_fetch_row($result1)){
  48.            echo "<option>$row[0]</option> ";
  49.     }
  50.     echo "</select> \n";  
  51.          
  52.     ?>    
  53.         <input type="submit" value="insertar"> <br><br>  
  54.         </form>
  55.      
  56.        
  57.         <form method="post" action="buscar3.php" name= "formulariobuscar" >
  58.        
  59.          Buscar:<input type="text" name="busca"> <br><br>
  60.          
  61.          <input type="submit" value="buscar"> <br><br>
  62.            
  63.         </form>
  64.      
  65.       <a href = "http://www.fxb4.com/juanmegasoft/0pf/lugares/formulariolugares.php">modificar lugares y capacidad</a>
  66.      
  67.       <br><br>
  68.      
  69.       </body>
  70.     </html>