CodeIgniter Forums

Full Version: Need Help here
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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..
(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();
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.
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.