Foros del Web » Programando para Internet » PHP »

tomar el name de un textbox

Estas en el tema de tomar el name de un textbox en el foro de PHP en Foros del Web. Hola tengo una pequeña inquietud que no he podido solucionar, resulta que tengo que imprimir un formulario html en un pdf, bueno yo utilizo fpdf, ...
  #1 (permalink)  
Antiguo 23/01/2012, 07:25
Avatar de JeMaGa  
Fecha de Ingreso: julio-2011
Ubicación: Bogota
Mensajes: 430
Antigüedad: 12 años, 9 meses
Puntos: 4
tomar el name de un textbox

Hola tengo una pequeña inquietud que no he podido solucionar, resulta que tengo que imprimir un formulario html en un pdf, bueno yo utilizo fpdf, pero tengo un problema al momento de generar el pdf no me toma los valores de todos los campos, es decir, tengo un formulario que tiene una lista en esta lista aparece la opcion de nuevo y una serie de codigos ya existentes, cuando yo selecciono nuevo no hay problema me crea el formulario bien, y me toma todos los datos, el problema biene cuando yo selecciono un codigo ya existente, este codigo me trae una consulta de la base de datos y me lo muestra en el formulario, y hay campos del formulario que sale de la consulta mysql, como hago para tomar el nombre de estos campos y mostrarlos en mi pdf

Código PHP:
Ver original
  1. <form name="MB11-176_iverchem" method="post" action="pdf.php" enctype="multipart/form-data">
  2.  
  3. <!-- Se crea un input de tipo oculto y se le pasa como valor el codigo del documento. -->
  4. <input type="hidden" name="No_Analisis" value="<?php echo $_POST['No_Analisis'] ?>">
  5.  
  6. <?PHP
  7.  
  8. require('Conexion.php');
  9.  
  10. $analis=$_POST['No_Analisis'];
  11.  
  12. $sql="select DISTINCT * FROM `certificado` where `No.Analisis` = '$analis'";
  13.  
  14. $result = mysql_query($sql,$Conexion) or die (mysql_error());
  15.  
  16. $row=mysql_num_rows($result);
  17.  
  18. if($row == 0){
  19.        
  20.     include('NuevoMB11-176.php');
  21.        
  22. }else {
  23.                            
  24. while ($filas=mysql_fetch_array($result)){
  25.    
  26.  
  27. ?>
  28.  
  29. <center>
  30.   <table width="60%" border="1">
  31.  
  32.   <tr>
  33.     <td width="14%"><strong>PRODUCTO:</strong></td>
  34.     <td colspan="3"><center>
  35.       <div id="busqueda">
  36.       <input type="text" name="producto" id="producto" size="99" value="<?php echo $filas['Producto'];?>">
  37.       </div>
  38.     </center></td>
  39.   </tr>
  40.  
  41.   <tr>
  42.     <td height="26"><strong>No.LOTE</strong></td>
  43.     <td width="20%">
  44.       <input type="text" name="lote" id="lote" value="<?php echo $filas['No.Lote'];?>"></td>
  45.     <td width="24%"><strong>FORMA FARMACEUTICA:</strong></td>
  46.     <td width="42%">
  47.       <input type="text" name="formula" id="formula" size="48" value="<?php echo $filas['FormaFarmaceutica'];?>"></td>
  48.   </tr>
  49.  
  50.   <tr>
  51.     <td><strong>CLIENTE:</strong></td>
  52.     <td colspan="3">
  53.       <input type="text" name="Cliente" id="Cliente" size="99" value="<?php echo $filas['Cliente']; ?>"></td>
  54.   </tr>
  55.  
  56.   <tr>
  57.     <td><strong>FECHA DE RECEPCI&Oacute;N:</strong></td>
  58.     <td><label for="Recep"></label>
  59.       <input id="fc_1326233462" type="text" READONLY name="fechaRecepMDE" title="YYYY-MM-DD" onClick="displayCalendar(this);" value="<?php echo $filas['FechaRecepcion'];?>"></td>
  60.     <td><strong>T&Eacute;CNICA:</strong></td>
  61.     <td>USP 32</td>
  62.   </tr>
  63.  
  64.   <tr>
  65.     <td><strong>FECHA DE SIEMBRA:</strong></td>
  66.     <td><label for="siem"></label>
  67.       <input id="fc_1326233488" type="text" READONLY name="fechaSiembraMDE" title="YYYY-MM-DD" onClick="displayCalendar(this);" value="<?php echo $filas['FechaSiembra'];?>"></td>
  68.     <td><strong>METODO:</strong></td>
  69.     <td><label for="me"></label>
  70.       <input type="text" name="me" id="me" size="48" value="<?php echo $filas['Metodo'];?>"></td>
  71.   </tr>
  72.  
  73.   <tr>
  74.     <td><strong>FECHA LECTURA</strong></td>
  75.     <td><label for="lect"></label>
  76.       <input id="fc_1326232694" type="text" READONLY name="fechaLecturaMDE" title="YYYY-MM-DD" onClick="displayCalendar(this);" value="<?php echo $filas['FechaLectura'];?>"></td>
  77.     <td><strong>PRESENTACI&Oacute;N:</strong></td>
  78.     <td>
  79.       <input type="text" name="Presen" id="Presen" size="48" value="<?php echo $filas['Presentacion'];?>"></td>
  80.   </tr>
  81. </table></center>
  82.  
  83. <p>
  84.  
  85. </p>
  86. <center><table width="84%" border="1">
  87.   <tr>
  88.     <td bgcolor="#999999"><b><center>MEDIOS USADOS</center></b></td>
  89.     <td bgcolor="#999999"><b><center>No.LOTE</center></b></td>
  90.     <td bgcolor="#999999"><b><center>RESULTADO</center></b></td>
  91.   </tr>
  92.  
  93.   [B]<?php
  94.  
  95. $Codigo=$_GET['codigo'];
  96.  
  97. echo $Codigo;
  98.  
  99. $analis=$_POST['No_Analisis'];
  100.  
  101. $sql2="select DISTINCT * FROM `medios` where `No.Analisis` = '$analis'";
  102.  
  103. $result2 = mysql_query($sql2,$Conexion) or die (mysql_error());
  104.  
  105. $row2=mysql_num_rows($result2);
  106.  
  107. while ($filas2=mysql_fetch_array($result2)){
  108.  
  109. ?>
  110.  
  111. <tr>
  112.  
  113.     <td><input name="medioss" type="text"  value="<?php echo $filas2['Medios_Usados']; ?>"      size="44" ></td>
  114.  
  115.     <td><input name="mdios" type="text"  value="<?php echo $filas2['No.Lote'];?>" size="30">    </td>
  116.  
  117.     <td><input name="medios2"  type="text" value="<?php echo $filas2['Resultado'];?>" size=    "30"></td>
  118.  
  119. </tr>
  120.  
  121. <?php[/B] // esta consulta devuelve mas  campos, pero esos campos no me los toma
  122.  
  123. }
  124.  
  125. ?>
  126.  
  127. </table></center>
  128.  
  129.  
  130. <center><table width="60%" border="1">
  131.   <tr>
  132.     <td colspan="3" bgcolor="#999999"><center><b>SUITABYLITY TEST</b></center></td>
  133.   </tr>
  134.  
  135.   <tr>
  136.     <td bgcolor="#999999"><center><b>MEDIOS USADOS</b></center></td>
  137.     <td bgcolor="#999999"><center><b>CONTROLACTIVIDAD</b></center></td>
  138.     <td bgcolor="#999999"><center><b>CONTROL ESTIRILIDAD</b></center></td>
  139.   </tr>
  140.  
  141.   <?php
  142.  
  143. $analis=$_POST['No_Analisis'];
  144.  
  145. $sql3="select DISTINCT * FROM `test` where `No.Analisis` = '$analis'";
  146.  
  147. $result3 = mysql_query($sql3,$Conexion) or die (mysql_error());
  148.  
  149. $row3=mysql_num_rows($result3);
  150.  
  151. while ($filas3=mysql_fetch_array($result3)){
  152.  
  153.   ?>
  154.  
  155.   <tr>
  156.     <td><label for="medios1"></label>
  157.       <input type="text" name="medios1" id="medios1" size="27" value="<?php echo $filas3['Medios_Usados'];?>"></td>
  158.     <td><input type="text" name="controlactividad" id="controlactividad" size="38" value="<?php echo $filas3['Control_actividad'];?>"></td>
  159.     <td><input type="text" name="controlesterilidad" id="controlesterilidad" size="38" value="<?php echo $filas3['Control_Estirilidad'];?>"></td>
  160.   </tr>
  161.   <?php
  162.  
  163. }
  164.  
  165. ?>
  166.  
  167.   <tr>
  168.     <td bgcolor="#999999" ><B>CONCEPTO:</B></td>
  169.     <td colspan="3" bgcolor="#999999"><input name="concepto" id="concepto" type="text" size="84" bgcolor="#999999" ></td>
  170.     </tr>
  171. </table></center>
  172.  
  173.  
  174. <p><strong>OBSERVACIONES:</strong> </p><textarea name="observaciones" cols="50" rows="5"></textarea>
  175. <p>&nbsp;</p>
  176. <p>&nbsp;</p>
  177.  
  178. <center>
  179. <table width="60%" >
  180.   <tr>
  181.     <td width="53%"><input name="Micro" type="text" size="30" value=""></td>
  182.   </tr>
  183.     <tr>
  184.     <td>Coordinadora Microbiologia</td>
  185.   </tr>
  186. </table>
  187. </center>
  188.  
  189. <center>
  190.   <p>
  191.     <a href="MenuCertificados.php">..:::Regresar:::.. </a>  
  192.     │
  193.     <input name="Crear" type="submit" value="Generar">
  194.   </p>
  195. </center>
  196.  
  197. <?php
  198.  
  199.     }
  200.            
  201. }
  202.  
  203. ?>
  204. </form>


Agradesco toda la ayuda
  #2 (permalink)  
Antiguo 23/01/2012, 10:49
Avatar de malakian  
Fecha de Ingreso: septiembre-2010
Ubicación: $malakian->Colombia();
Mensajes: 469
Antigüedad: 13 años, 7 meses
Puntos: 45
Respuesta: tomar el name de un textbox

Hola, obviamente estas enviando datos al pdf.php, ahi deberias recoger los datos que envias, y supongo que deberias hacer otra consulta a la BD, si no te sale seguramente es por que el query esta fallando o no estas recogiendo los datos, muestra tu archivo pdf.php
y trata de explicarte un poco mejor
__________________
Guitar Loco, Desarrollador Web PHP
Sigueme: @jose1x
  #3 (permalink)  
Antiguo 23/01/2012, 13:17
Avatar de JeMaGa  
Fecha de Ingreso: julio-2011
Ubicación: Bogota
Mensajes: 430
Antigüedad: 12 años, 9 meses
Puntos: 4
Respuesta: tomar el name de un textbox

Muchas gracias!!! que pena por no haberme explicado mejor!!!, pero ya solucione el preoblema que tenia.
Pues como no se sabe cuantos campos de texto va a devolver la consulta, entonces lo que hice fue un campo de texto como arreglo, luego tome el valor del arreglo, y lo puse en una variable para que el pdf la tomara, aqui esta el codigo

Código PHP:
Ver original
  1. <center><table width="84%" border="1">
  2.   <tr>
  3.     <td bgcolor="#999999"><b><center><strong>MEDIOS USADOS</strong></center></b></td>
  4.     <td bgcolor="#999999"><center>
  5.       <strong>      No.LOTE
  6.       </strong>
  7.     </center></td>
  8.     <td bgcolor="#999999"><b><center>RESULTADO</center></b></td>
  9.   </tr>
  10.  
  11.   <?php
  12.  
  13. $Codigo=$_GET['codigo'];
  14.  
  15. echo $Codigo;
  16.  
  17. $analis=$_POST['No_Analisis'];
  18.  
  19. $sql2="select DISTINCT * FROM `medios` where `No.Analisis` = '$analis'";
  20.  
  21. $result2 = mysql_query($sql2,$Conexion) or die (mysql_error());
  22.  
  23. $row2=mysql_num_rows($result2);
  24.  
  25. while ($filas2=mysql_fetch_array($result2)){
  26.  
  27. ?>
  28.  
  29. <tr>
  30.  
  31.     <td><input name="medioss[]" type="text"  value="<?php echo $filas2['Medios_Usados']; ?>"        size="44" ></td>
  32.  
  33.     <td><input name="mdios[]" type="text"  value="<?php echo $filas2['No.Lote'];?>" size="30">    </td>
  34.  
  35.     <td><input name="medios2[]"  type="text" value="<?php echo $filas2['Resultado'];?>" size=    "30"></td>
  36.  
  37. </tr>
  38.  
  39. <?php
  40.  
  41. }
  42.  
  43. ?>
  44.  
  45. </table></center>

y en el pdf lo toma asi

Código PHP:
Ver original
  1. /*---------------------------- MEDIOS UTILIZADOS -------------------------------*/
  2. $data24 = array_slice($_POST['medioss'],0,1);
  3. foreach ($data24 as $actual)
  4.  
  5. $datamedios = array_slice($_POST['mdios'],0,1);
  6. foreach ($datamedios as $actual2)
  7.  
  8. $datamedios1 = array_slice($_POST['medios2'],0,1);
  9. foreach ($datamedios1 as $actual1)
  10.  
  11. $segundomedio = array_slice($_POST['medioss'],1,1);
  12. foreach ($segundomedio as $segundomedio1)
  13.  
  14. $segundolote = array_slice($_POST['mdios'],1,1);
  15. foreach ($segundolote as $segundolote1)
  16.  
  17. $segundoresultado = array_slice($_POST['medios2'],1,1);
  18. foreach ($segundoresultado as $segundoresultado1)

asi lo llame en el pdf

Código PHP:
Ver original
  1. $this->Cell(60,5,'MEDIOS USADOS',1,0,'C');
  2.       $this->Cell(46,5,'LOTE No.',1,0,'C');
  3.       $this->Cell(46,5,'RESULTADO',1,0,'C');
  4.       $this->Ln();
  5.      
  6.       $this->Cell(60,7,$actual,1,0,'C');
  7.       $this->Cell(46,7,$actual2,1,0,'C');
  8.       $this->Cell(46,7,$actual1,1,0,'C');
  9.       $this->Ln();
  10.      
  11.       $this->Cell(60,7,$segundomedio1,1,0,'C');
  12.       $this->Cell(46,7,$segundolote1,1,0,'C');
  13.       $this->Cell(46,7,$segundoresultado1,1,0,'C');
  14.       $this->Ln();

y funciono

Etiquetas: formulario, html, mysql, sql, textbox, tomar
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 12:25.