Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] Pasar varios valores

Estas en el tema de Pasar varios valores en el foro de PHP en Foros del Web. Hola a todos, haber si me podeis ayudar: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código PHP: Ver original <form id="buscador" name="buscador" method="post" action=" <?php echo $_SERVER [ 'PHP_SELF' ] ...
  #1 (permalink)  
Antiguo 08/03/2016, 03:47
Avatar de GUAPISNEY  
Fecha de Ingreso: marzo-2016
Mensajes: 14
Antigüedad: 8 años, 1 mes
Puntos: 0
Pasar varios valores

Hola a todos, haber si me podeis ayudar:

Código PHP:
Ver original
  1. <form id="buscador" name="buscador" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  2.       <table width="419" border="3" align="center">
  3.   <tr>
  4.     <th height="41" colspan="2" bgcolor="#7E7EEF" scope="col"><div align="center" class="Estilo3">BUSCAR POR SEDE </div></th>
  5.     </tr>
  6.   <tr>
  7.     <td height="29" bgcolor="#C7C7F8"><div align="center">
  8.      
  9.       <p>
  10.         <select name="lista"  >
  11.           <option style="background:blue; color:white" value="fibra" selected="selected">FIBRA</option>
  12.           <option style="background:red; color:white" value="shdsl">SHDSL</option>
  13.           <option style="background:blue; color:white" value="radio">RADIO</option>
  14.    
  15.         </select>
  16.       </p>
  17.      
  18.     </div>      </td>
  19.     <td width="113" bgcolor="#C7C7F8"><div align="center">
  20.       <input type="submit" name="buscador" class="boton peque aceptar" value="buscar" />
  21.     </div></td>
  22.   </tr>
  23. </table>
  24.    
  25. </form>
  26.  
  27.  
  28.  <div align="center">
  29.  
  30.    
  31.       <?php
  32.     include("conexion.php");
  33.     $listar = trim($_POST['lista']);
  34.    
  35.    
  36.     $query=("select * from $listar ORDER BY codigo")or die(mysql_error());
  37.     $resultado= mysql_query($query);
  38.     ?>
  39.     <br />
  40.    
  41.     <table width="772" height="42" border="3" bgcolor="#C7C7F8">
  42.         <tr>
  43.           <th width="92" height="32" bgcolor="#000033" scope="col"><span class="Estilo9">CÓDIGO</span></th>
  44.           <th width="111" bgcolor="#000033" scope="col"><span class="Estilo9">PROVINCIA</span></th>
  45.           <th width="136" bgcolor="#000033" scope="col"><span class="Estilo9">Adm (RCL)</span></th>
  46.           <th width="131" bgcolor="#000033" scope="col"><span class="Estilo9">INTERFACE</span></th>
  47.           <th width="151" bgcolor="#000033" scope="col"><span class="Estilo9">VRF</span></th>
  48.           <th width="107" bgcolor="#000033" scope="col">EVENTO</th>
  49.         </tr>
  50.       </table>
  51.      
  52.       <?php
  53.    
  54.    
  55.     $num_fila = 0;
  56.     while($row=mysql_fetch_assoc($resultado))
  57.     {
  58.    
  59.      
  60.    
  61.             if ($num_fila%2==0) {
  62.         ?>
  63.        
  64.          <table width="772" height="42" border="3" bgcolor="#C7C7F8">
  65.         <tr>
  66.           <th width="92" height="32" scope="col"><span class="Estilo5"><?php echo $row['codigo']; ?></span></th>
  67.           <th width="112" scope="col"><span class="Estilo5"><?php echo $row['provincia']; ?></span></th>
  68.           <th width="135" scope="col"><span class="Estilo5"><?php echo $row['administrativor']; ?></span></th>
  69.           <th width="131" scope="col"><span class="Estilo5"><?php echo $row['interface']; ?></span></th>
  70.           <th width="151" scope="col"><span class="Estilo5"><?php echo $row['vrf']; ?></span></th>
  71.           <th width="107" bgcolor="#000033" scope="col"><a href="mostrar2.php?id=<?php echo $row['id'] & $listar ?>">MOSTRAR</th>
  72.         </tr>
  73.       </table>
  74.      
  75.       <?php

RESUMO:
1.- <select name="lista" > Aqui elijo en que tabla quiero que busque e imprimo algunos campos de esa tabla.
2.- <a href="mostrar2.php?id=<?php echo $row['id'] & $listar ?>">MOSTRAR</th>

y aqui cuando clico quiero que me muestre el ese id y sus campos en otra pagina...pero solo puedo capturar el id con:
$v1 = $_GET['id'];
pero no se en que tabla buscar porque no se como pasar $listar

Alguna idea?
  #2 (permalink)  
Antiguo 08/03/2016, 08:26
Avatar de Perr0  
Fecha de Ingreso: mayo-2005
Ubicación: Santiago de Chile, Chile
Mensajes: 676
Antigüedad: 19 años
Puntos: 79
Respuesta: Pasar varios valores

para pasar la variable de este ejemplo

Código:
<a href="mostrar2.php?id=<?php echo $row['id'] & $listar ?>">MOSTRAR</th>
debería ser así:
Código:
<a href="mostrar2.php?id=<?php echo $row['id']."&variable_get=".$listar ?>">MOSTRAR</a></th>
ojo agregué &variable_get= y el cierre de "a" </a>

salu2
__________________
Numerador Mp3 en Access =)
http://www.mediafire.com/download/r9...pdw/mp3(2).zip
  #3 (permalink)  
Antiguo 08/03/2016, 10:54
Avatar de GUAPISNEY  
Fecha de Ingreso: marzo-2016
Mensajes: 14
Antigüedad: 8 años, 1 mes
Puntos: 0
Respuesta: Pasar varios valores

ey , muchas gracias, lo pruebo y te digo.
  #4 (permalink)  
Antiguo 08/03/2016, 16:01
Avatar de GUAPISNEY  
Fecha de Ingreso: marzo-2016
Mensajes: 14
Antigüedad: 8 años, 1 mes
Puntos: 0
Respuesta: Pasar varios valores

Ey Perro , lo acabo de probar y no lo consigo, mira ,


Código PHP:
Ver original
  1. <a href="mostrar2.php?id=<?php echo $row['id']."&variable_get=".$listar ?>">MOSTRAR</a></th>

la variable esta lleva el & ,es asi?
puedo llamarla &x=".$listar?
y otra cosa como la recojo en la siguiente pagina? asi recojo el id
Código PHP:
Ver original
  1. $v1 = $_GET['id'];


como seria?


Código PHP:
Ver original
  1. $list = $_GET['x'];
  #5 (permalink)  
Antiguo 08/03/2016, 16:06
Avatar de GUAPISNEY  
Fecha de Ingreso: marzo-2016
Mensajes: 14
Antigüedad: 8 años, 1 mes
Puntos: 0
Respuesta: Pasar varios valores

ey Perro , ya lo consegui


para el que quiera saber , en la siguiente pagina lo recogí con:
Código Java:
Ver original
  1. $list = $_GET['variable_get'];

GRACIAS.
  #6 (permalink)  
Antiguo 08/03/2016, 16:20
Avatar de Perr0  
Fecha de Ingreso: mayo-2005
Ubicación: Santiago de Chile, Chile
Mensajes: 676
Antigüedad: 19 años
Puntos: 79
Respuesta: Pasar varios valores

asi es, lo que coloques entre el "&" y el "=" es el nombre de variable, ejemplo ...&variable=...., entonces la recibirás así en la pagina $_GET['variable']


saludos
__________________
Numerador Mp3 en Access =)
http://www.mediafire.com/download/r9...pdw/mp3(2).zip
  #7 (permalink)  
Antiguo 08/03/2016, 16:53
Avatar de GUAPISNEY  
Fecha de Ingreso: marzo-2016
Mensajes: 14
Antigüedad: 8 años, 1 mes
Puntos: 0
Respuesta: Pasar varios valores

Perfecto, muchas gracias tio

Etiquetas: mysql, select, sql, tabla
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 00:48.