CodeIgniter Forums
Need Help here - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Need Help here (/thread-64137.html)



Need Help here - morocho1979 - 01-19-2016

i have this php code i need to convert to codeigniter , some can help me im really new o this 


$pdf->SetFillColor(210,210,210); //linea gris
$pdf->SetTextColor(0,0,0); //texto negro
$header=array('GRADO','CEDULA','CARNET','NOMBRES Y APELLIDOS');
$pdf->SetWidths(array(30,40,30,80));
$pdf->SetAligns(array('C','C','C','L')); //para las celdas de la tabla

//imprimir encabezado
for($l=0;$l<count($header);$l++)
$pdf->Cell($pdf->widths[$l],5,$header[$l],1,0,'C',true);
$pdf->Ln();


thx for the help


RE: Need Help here - sv3tli0 - 01-19-2016

Converting PHP to CodeIgniter is impossible as CodeIgniter is PHP framework Smile

You have to provide more code and what do you need exactly. At the moment you have just display part of some code and nothing more..

And I don't think that you will get help this way..


RE: Need Help here - morocho1979 - 01-19-2016

(01-19-2016, 06:20 AM)sv3tli0 Wrote: Converting PHP to CodeIgniter is impossible as CodeIgniter is PHP framework Smile

You have to provide more code and what do you need exactly. At the moment you have just display part of some code and nothing more..

And I don't think that you will get help this way..

maybe I did not explain well, im working with fpdf and i need to do a FOR , like i paste with that array and using in codeigniter 



Code:
    $pdf->SetFillColor(210,210,210); //linea gris
            $pdf->SetTextColor(0,0,0); //texto negro
            $header=array('GRADO','C�DULA','CARNET','NOMBRES Y APELLIDOS');
            $pdf->SetWidths(array(30,40,30,80));
            $pdf->SetAligns(array('C','C','C','L')); //para las celdas de la tabla
                    
            //imprimir encabezado
            for($l=0;$l<count($header);$l++)
                $pdf->Cell($pdf->widths[$l],5,$header[$l],1,0,'C',true);
            $pdf->Ln();



RE: Need Help here - Diederik - 01-19-2016

If you place existing (working) code it should work within a controller. Codeigniter uses php, its not a replacement. So you can use for loops etc basicly everywhere.


RE: Need Help here - Wouter60 - 01-19-2016

In your existing code, you're working with an object named $pdf. I assume this depends on a third-party library.
You can use this in CI as well.
E.g. the fpdf library. The Fpdf.php file goes into the application/libraries folder. In CI 3.x it must have a first capital letter.

In my controller where I want to generate a pdf, I have this code:
PHP Code:
$this->load->library('fpdf'); 
This creates an object.
The methods and properties of this object are addressed like this:
PHP Code:
$this->fpdf->AddPage('L');
$this->fpdf->SetFont('Helvetica','',11);
..
..
$this->fpdf->Output("mydocument.pdf","D"); 
Etc.