@rollin
To export MySQL data to PDF in CodeIgniter, you can follow these steps:
Here is an example of how you can generate a PDF file in CodeIgniter:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
public function exportToPdf(){ // Load the TCPDF library $this->load->library('pdf'); // Fetch data from MySQL database $data['results'] = $this->your_model_name->get_data(); // Generate PDF file $this->pdf->setPaper('A4', 'landscape'); $this->pdf->AddPage(); foreach ($data['results'] as $result) { $this->pdf->Cell(0, 10, $result['column_name'], 0, 1); } $this->pdf->Output('filename.pdf', 'D'); } |
Note: Make sure to configure the TCPDF library correctly in CodeIgniter and set the correct path to the library in your configuration file.