使用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