使用codeigniter我創建一個表單,我將數據插入MySQL數據庫。完成插入後,我想檢索數據爲PDF文件。使用codeigniter導出來自mysql數據庫的pdf文件
在modeld我的文件名 - membership_model.php。 鑑於頁我有形式的名字 - send_form.php 但發送數據後,我有一個成功的頁面名稱signup_successful.php這裏是一個鏈接導出爲PDF按鈕誰打電話topdf()在登錄頁面。但是不起作用。請幫助topdf功能。
鑑於文件夾 - signup_successful.php
<p>Your data has been sent.
<?php echo anchor('topdf', 'Export as PDF');?>
</p>
控制器文件夾
的login.php
<?php
class Login extends Controller {
function index()
{
parent::Controller();
$this->load->helper('pdf_helper');
}
function data_info()
{
$data['main_content'] = 'data_form';
$this->load->view('includes/template', $data);
}
function sent_data()
{
$this->load->library('form_validation');
// field name, error message, validation rules
$this->form_validation->set_rules('first_name', 'Name', 'trim|required');
$this->form_validation->set_rules('last_name', 'Last Name', 'trim|required');
$this->form_validation->set_rules('email_address', 'Email Address', 'trim|required|valid_email');
if($this->form_validation->run() == FALSE)
{
$this->load->view('data_form');
}
else
{
$this->load->model('membership_model');
if($query = $this->membership_model->send_data())
//create_member call model create_member
{
$data['main_content'] = 'signup_successful';
$this->load->view('includes/template', $data);
}
else
{
$this->load->view('data_form');
}
}
}
function topdf()
{
$this->load->library('cezpdf');
$this->load->helper('pdf_helper');
prep_pdf();
$data['member']= $this->membership_model->alldata();
$titlecolumn = array(
'first-name' => 'First-name',
'last_name' => 'Last_name',
'email_address' => 'Email_address'
);
$this->cezpdf->ezTable($data['member'], $titlecolumn,'Member Data');
$this->cezpdf->ezStream();
}
}
*「但是不起作用」*不會飛到這裏。更加詳細一些。 –
那麼有沒有錯誤,它是壞的? – MonkeyZeus