Foros del Web » Programando para Internet » PHP »

while php + boton

Estas en el tema de while php + boton en el foro de PHP en Foros del Web. buenas noches a todos, aqui presento mi caso, en esta oportunidad me toco a mi preguntar, sere preciso... aqui esta mi codigo Código PHP:   <form id="form3" name="form3" method="post" action="buscadorporci.php"> ...
  #1 (permalink)  
Antiguo 08/04/2011, 21:49
 
Fecha de Ingreso: febrero-2011
Mensajes: 64
Antigüedad: 13 años, 1 mes
Puntos: 0
while php + boton

buenas noches a todos, aqui presento mi caso, en esta oportunidad me toco a mi preguntar, sere preciso... aqui esta mi codigo

Código PHP:
  <form id="form3" name="form3" method="post" action="buscadorporci.php">
          <table width="591" border="3" align="center" cellpadding="0" cellspacing="0">
            <tr align="center">
              <td width="40" bgcolor="#0000CC">&nbsp;</td>
              <td width="95" bgcolor="#0000CC"><span class="Estilo6">FECHA</span></td>
              <td width="195" bgcolor="#0000CC"><div align="center" class="Estilo21 Estilo19"><strong>CEDULA</strong></div></td>
              <td width="105" bgcolor="#0000CC"><div align="center" class="Estilo21 Estilo19"><strong>NOMBRE</strong></div></td>
              <td width="140" bgcolor="#0000CC"><div align="center" class="Estilo21 Estilo19"><strong>COMENTARIO</strong></div></td>
            </tr>
            <?php 
            
                  $sqlfech 
"SELECT * FROM cvregistro WHERE registro= '1' ";
                  
$resfech=mysql_query($sqlfech,$link); 
                  while(
$filfech=mysql_fetch_array($resfech))
                  {
                
                        
                
                   
?>
            <tr bgcolor="#FFFFFF">
              <td height="26"><label>
                <input type="submit" name="button" id="ci" value="ver" src="buscadorporci.php"/>
              </label></td>
              <td><span class="Estilo24">&nbsp;<?php echo $filfech[6]; ?></span></td>
              <td><span class="Estilo22 style12 Estilo20 Estilo24"><strong>&nbsp;
                      <label><strong>
                      <input name="ci" type="text" id="ci" value="<?php echo $filfech[2]; ?>" />
                      </strong></label>
              </strong></span></td>
              <td><span class="Estilo22 style12 Estilo20 Estilo24"><strong>&nbsp;<?php echo $filfech[1]; ?></strong></span></td>
              <td><span class="Estilo22 style12 Estilo20 Estilo24"><strong>&nbsp;<?php echo $filfech[7]; ?></strong></span></td>
            </tr>
            <?php 
                
                
}
                
                
?>
          </table>
      </form>
"mediante este while me va llenando una tabla, y me va genrando por cada item de la tabla un boton llamado value VER, lo que quiero hacer es que este boton me tome el valor del input text o envie ese valor mediante post al action del form"

no se si me explique muy bien es como que sale una lista de varios nombre y por cada nombre haya un boton que al oprimir muestre los datos de esa cedula
  #2 (permalink)  
Antiguo 08/04/2011, 21:56
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 15 años, 11 meses
Puntos: 2534
Respuesta: while php + boton

pues si te explicaste, pero, ¿el problema es?

aunque me adelanto un poco, ya se por donde vas, y es que usas el mismo name/id por cada elemento dentro del bucle... lo cual no es posible, pues dichos valores deberían ser únicos...

una técnica, al menos con los name es que uses un formato parecido a este:
Código HTML:
<input name="foo[]"/> 
eso asegura que pueden existir varios elementos agrupados por el mismo name, así, de enviarse no solo llega un valor, sino una colección de los mismos...

¿que hace falta un botón? ¿porque no lo agregas?

¿que hace falta como mostrar datos específicos porque lo demás ya lo tienes resuelto? hmmm...
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 08/04/2011, 22:08
 
Fecha de Ingreso: febrero-2011
Mensajes: 64
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: while php + boton

ok me explico mejor, fijate que en el action del form, dice buscadorporci.php en esta pagina toma mediante $_POST el valor enviado y hace la busqueda y me imprime los datos de esa cedula, pero la duda que tengo es como hacer para que cada boton generado del while, me tome el valor del input text, o bien envie este valor a la pagina buscadorporci.php... ejem

VER(boton) 2011-04-08 17646(cedula) juan(nombre)

VER(boton) 2011-04-05 12232(cedula) maria(nombre)

VER(boton) 2011-04-01 15345(cedula) andres(nombre)


entonces que cuando oprimas VER me tome el valor del input text que seria la cedula y la envie a la pagina buscadorporci.php
  #4 (permalink)  
Antiguo 08/04/2011, 22:18
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 15 años, 11 meses
Puntos: 2534
Respuesta: while php + boton

claro, se entiende a la perfección!

en breve, hay dos formas simples de hacer esto:

con enlaces,
Código PHP:
<a href="?script.php?id=<?php echo $id?>">link</a>
o con botones
Código PHP:
<input type="submit" name="action[<?php echo $id?>]" value="action"/>
como tu prefieras...

[1] http://www.php.net/variables.external
[2] http://www.forosdelweb.com/f18/aport...uladas-662159/
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #5 (permalink)  
Antiguo 08/04/2011, 22:41
 
Fecha de Ingreso: febrero-2011
Mensajes: 64
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: while php + boton

aqui pego lo que hice



<form id="action" name="form3" method="post" action="prueba.php">
<table width="591" border="3" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<td width="40" bgcolor="#0000CC">&nbsp;</td>
<td width="95" bgcolor="#0000CC"><span class="Estilo6">FECHA</span></td>
<td width="195" bgcolor="#0000CC"><div align="center" class="Estilo21 Estilo19"><strong>CEDULA</strong></div></td>
<td width="105" bgcolor="#0000CC"><div align="center" class="Estilo21 Estilo19"><strong>NOMBRE</strong></div></td>
<td width="140" bgcolor="#0000CC"><div align="center" class="Estilo21 Estilo19"><strong>COMENTARIO</strong></div></td>
</tr>
<?php

$sqlfech = "SELECT * FROM cvregistro WHERE registro= '1' ";
$resfech=mysql_query($sqlfech,$link);
while($filfech=mysql_fetch_array($resfech))
{

$cont=$cont+1;

?>
<tr bgcolor="#FFFFFF">
<td height="26"><label>
<input type="submit" name="action[<?php $filfech[2]; ?>]" value="action"/>
</label></td>
<td><span class="Estilo24">&nbsp;<?php echo $filfech[6]; ?></span></td>
<td><span class="Estilo22 style12 Estilo20 Estilo24"><strong>&nbsp;
<label><strong>
<input name="ci" type="text" value="<?php echo $filfech[2]; ?>" />
</strong></label>
</strong></span></td>
<td><span class="Estilo22 style12 Estilo20 Estilo24"><strong>&nbsp;<?php echo $filfech[1]; ?></strong></span></td>
<td><span class="Estilo22 style12 Estilo20 Estilo24"><strong>&nbsp;<?php echo $filfech[7]; ?></strong></span></td>
</tr>
<?php

}

?>
</table>
</form>




lo que quiero es que el valor del boton o del input lo muestre aqui


<input type="text" name="textfield" id="textfield" value="<?php $_POST["action"] ?>" />


que es pagina a donde redirecciona el form anterior
  #6 (permalink)  
Antiguo 08/04/2011, 22:56
 
Fecha de Ingreso: febrero-2011
Mensajes: 64
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: while php + boton

Cita:
Iniciado por pateketrueke Ver Mensaje
claro, se entiende a la perfección!

en breve, hay dos formas simples de hacer esto:

con enlaces,
Código PHP:
<a href="?script.php?id=<?php echo $id?>">link</a>
o con botones
Código PHP:
<input type="submit" name="action[<?php echo $id?>]" value="action"/>
como tu prefieras...

[1] [url]http://www.php.net/variables.external[/url]
[2] [url]http://www.forosdelweb.com/f18/aporte-listas-vinculadas-662159/[/url]



hermano en verdad disculpa si estoy muy cerrado en el entendimiento de esta parte, pero el valor que me envia y me recibe en la otra pagina es Array, claro coloco a recibir los datos que toma el boton cuando se hace el while
  #7 (permalink)  
Antiguo 08/04/2011, 23:12
 
Fecha de Ingreso: febrero-2011
Mensajes: 64
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: while php + boton



algo asi es lo que se quiere, y en el boton VER envie lo que esta en el text correspondiente
  #8 (permalink)  
Antiguo 08/04/2011, 23:55
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 15 años, 11 meses
Puntos: 2534
Respuesta: while php + boton

claro que el valor que devuelve es Array, porque no estas obteniendo la clave de mismo... que en si sería el $id que le pasas si usas la versión el botón, por eso deje los enlaces para que consultaras...
Código PHP:
$id key($_POST['action']); 
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #9 (permalink)  
Antiguo 09/04/2011, 00:11
 
Fecha de Ingreso: febrero-2011
Mensajes: 64
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: while php + boton

Cita:
Iniciado por pateketrueke Ver Mensaje
claro que el valor que devuelve es Array, porque no estas obteniendo la clave de mismo... que en si sería el $id que le pasas si usas la versión el botón, por eso deje los enlaces para que consultaras...
Código PHP:
$id key($_POST['action']); 
aqui tengo la solucion, para las personas que se topen con este tema, es sencillo, por cada vuelta del while va a generar un form

<?php

$sqlfech = "SELECT * FROM cvregistro WHERE registro= '1' ";
$resfech=mysql_query($sqlfech,$link);
while($filfech=mysql_fetch_array($resfech))
{


echo "<FORM action='buscadorporci.php' method='post'>";

?>

<table width="200" border="1">
<tr bgcolor="#FFFFFF">
<td>&nbsp;<?php echo $filfech[0]; ?></td>
<td>&nbsp;<input type="text" name="ci" id="textfield" value="<?php echo $filfech[2]; ?>" /></td>
<td>&nbsp;<?php echo $filfech[3]; ?></td>
<td>&nbsp;<input type="submit" name="boton" id="boton" value="ver" /></td>
</tr>
</table>


<?php
echo " </FORM>" ;
}

?>



ASI CUANDO SE MANDE LA INFO VA HACER POR CADA FORMULARIO INDIVIDUAL Y TOMARA EL VALOR DEL TEXT QUE DESEE

GRACIAS POR LA AYUDA A pateketrueke mis repetos por ser tan colaborador

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:26.