Problems when creating a pdf created with fpdf

0

My problem is that when creating the pdf the table where I create it shows me the cut data

As you can see in the image in services performed, it shows me the correlative data and I want you to show them one separated from the other one downwards

code extract that creates the table

    function cabecera($cabecera){
    $this->SetXY(35,105);
    $this->SetFont('Arial','B',15);
    foreach($cabecera as $columna)
    {
        $this->Cell(55,7,$columna,1, 2 , 'L' ) ;
    }
}

function datos($datos){

    $this->SetXY(90,105);
    $this->SetFont('Arial','',12);
    foreach ($datos as $columna)
    {   $this->Cell(80,7,utf8_decode($columna['estado']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['id']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['nombre']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['rut']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['email']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['phone']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['mensaje']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['servicio']),'TRB',2,'L' );

    }
}

//El método tabla integra a los métodos cabecera y datos
function tabla($cabecera,$datos){
    $this->cabecera ($cabecera) ;
    $this->datos($datos);
}


    }//fin clase PDF
   ?>       

And with this code extract I extract them from my database to create the pdf

   public function seleccionar_persona($id)
  {
    $q = "select id , nombre, rut,
                 email, phone,
                 direccion,mensaje,estado,servicio  from contribuyente
                 where
                 id = '$id'";
    
asked by Daniela 06.06.2018 в 17:51
source

1 answer

0

You have to create a new loop that explodes the services and will continue to put cells.

The problem is that I see that you do not have them separated in database in any way. so it makes the task very difficult. it's time to save them separate with a weird character (; #), and make explode(';', servicios);

function datos($datos){
    $this->SetXY(90,105);
    $this->SetFont('Arial','',12);
    foreach ($datos as $columna)
    {   $this->Cell(80,7,utf8_decode($columna['estado']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['id']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['nombre']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['rut']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['email']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['phone']),'TRB',2,'L' );
        $this->Cell(80,7,utf8_decode($columna['mensaje']),'TRB',2,'L' );

        $serv_tmp = explode(";",$columna['servicio']);
        for($i = 0; $i < count($serv_tmp); ++$i) {

            $this->Cell(80,7,utf8_decode($serv_tmp[$i]),'TRB',2,'L' );
        }
    }
}
    
answered by 06.06.2018 в 18:19