Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/05/2014, 07:15
sarrhen
 
Fecha de Ingreso: mayo-2013
Ubicación: San Vicente
Mensajes: 127
Antigüedad: 11 años
Puntos: 1
Sonrisa Crear una tabla fpdf obteniendo los datos de un text dinamico

Necesito crear una tabla simple de dos columnas obteniendo los datos de un text dinamico que creado y solo me imprime una columna

Esta es la Clase

Código PHP:
Ver original
  1. <?php
  2. require('./fpdf17/fpdf.php');
  3.  
  4. class PDF extends FPDF
  5. {
  6.    
  7.    
  8.  
  9.     function cabeceraVertical($cabecera)
  10.     {
  11.         $this->SetXY(30, 45);
  12.         $this->SetFont('Arial','B',11);
  13.         $this->SetTextColor(0,0,0);
  14.         $this->SetDrawColor(0,0,0);
  15.         $this->SetLineWidth(0.3);
  16.         foreach($cabecera as $columna)
  17.         {
  18.             //Parámetro con valor 2, hace que la cabecera sea vertical
  19.             $this->Cell(60,10, utf8_decode($columna),1, 2 , 'L' );
  20.         }
  21.     }
  22.  
  23.     function datosVerticales($datos)
  24.     {
  25.         $this->SetXY(30, 45); //40 = 10 posiciónX_anterior + 30ancho Celdas de cabecera
  26.         $this->SetFont('Arial','b',12); //Fuente, Normal, tamaño
  27.         $this->SetTextColor(0,0,0);
  28.         $this->SetDrawColor(0,0,0);
  29.         $this->SetLineWidth(0.3);
  30.         foreach($datos as $columna)
  31.         {
  32.             $this->Cell(130,10, utf8_decode($columna),1, 2 , 'R' );
  33.         }
  34.     }
  35.  
  36.    
  37. } // FIN Class PDF
  38. ?>

Este es el text Dinamico

Código PHP:
Ver original
  1. <?php
  2. if($_POST['concepto']){
  3.  
  4. $concepto[]=$_POST["concepto"];
  5. $valor[]= $_POST["valor"];
  6.  
  7. $lista = array($concepto);
  8.  
  9. for($i=0;$i<count($concepto)-1;$i++){
  10. echo $concepto[$i]."->".$valor[$i]."<br>";
  11. }
  12.  
  13. }
  14. ?>
  15. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head>
  18. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  19.  
  20. <meta content="jquery, forumlario dinamico, tutorial" name="keywords"/>
  21.  
  22. <title>Formulario Dinamico</title>
  23. <script type="text/javascript" src="textdinamicos/jquery.min.js"></script>
  24. <script type="text/javascript" src="textdinamicos/jquery.addfield2.js"></script>
  25.  
  26. <div id="stylized" class="myform" style="margin:20px auto;">
  27.     <form id="form" name="form" method="post" action="tablasDinamicas.php">
  28.  
  29. <div id="material_comprado"> </div>  
  30.  
  31. <h1>Campos Din&aacute;mico</h1>
  32.  
  33. <label><span class="small">A&ntilde;ade las conceptos</span>
  34. </label><br />
  35.     <div id="div_1">
  36.     <label>Codigo de Producto</label>
  37.         <input  type="text"  name="concepto[]" id="concepto" style="width:200px;" /> <br>
  38.     <label>Valor</label>
  39.         <input  type="text"  name="valor[]" id="valor" style="width:200px;" />
  40.             <input class="bt_plus" id="1" type="button" value="+" /><div class="error_form">
  41.     </div>
  42.    
  43.    
  44. </div>
  45.  
  46. <button type="submit" class="boton">Enviar</button>
  47. <div class="spacer"></div>
  48. </form>

y aqui es donde lo procesa

Código PHP:
Ver original
  1. <?php
  2.  
  3. $FirstArray = ($_POST['concepto']);
  4. $SecondArray = ($_POST['valor']);
  5. include_once('./claseDinamicas.php');
  6. $pdf = new PDF();
  7.  
  8. $pdf->AddPage();
  9.  
  10. foreach($FirstArray as $index => $value) {
  11.    
  12.   $FirstArray[$index];
  13.            
  14.         $SecondArray[$index];
  15.      
  16.  
  17. }
  18.  
  19.   $miCabecera = array($FirstArray[$index]);
  20. $misDatos = array($SecondArray[$index]);
  21.  
  22.  
  23. $pdf->cabeceraVertical($miCabecera);
  24. $pdf->datosVerticales($misDatos);
  25.  
  26.  
  27.  
  28. $pdf->Output(); //Salida al navegador
  29. ?>

Me podrian hechar la mano por que lo que quiero es que si he mandado cuatro valores poder ver esos cuatro valores o mas dibujandos en la tabla y no se donde es mi error