0

我正在尝试插入一些写在文本字段中的文本,有两个字段一个是票,它工作正常另一方面报告没有正确插入到 sql。这是我的视图代码

<td><input type='text' id='ticket' name='ticket'/></td>
<td><textarea id='report' name='report'>enter text report</textarea></t

这是我的控制器

function testUpload(){
    $data=array(
        'ticket'=>$this->input->post('ticket'),
        'report'=>$report=$this->input->post('repost')
    );
    $this->load->model('patient_model');
    $this->patient_model->insertReport($data);
}

这是我的模型

function insertReport($data){
    $this->db->insert('report',$data);
}
4

4 回答 4

4

Try below code, change repost to report

function testUpload(){
        $data=array(
        'ticket'=>$this->input->post('ticket'),
        'report'=>$report=$this->input->post('report')
        );

    $this->load->model('patient_model');
    $this->patient_model->insertReport($data);
}

EDIT :-

Seems like you have edited your question,

Initially it was 'report'=>$report=$this->input->post('tr')

Now you have change'report'=>$report=$this->input->post('repost')

Both are wrong...

于 2013-01-23T10:07:02.163 回答
2

You have name='report' but $this->input->post('repost')

You need to avoid making typos when referencing your field.

于 2013-01-23T10:07:33.020 回答
2

尝试这个。

function testUpload(){
    $data=array(
        'ticket'=>$this->input->post('ticket'),
        'report'=>$this->input->post('report')
    );
    $this->load->model('patient_model');
    $this->patient_model->insertReport($data);
}

并且您必须确定表格报告中必须存在字段报告。

于 2013-01-23T21:44:38.263 回答
2

请更改repostreport

因为您的文本区域名称是报告

因此,您的控制器应如下所示...

function testUpload(){
    $data=array(
        'ticket'=>$this->input->post('ticket'),
        'report'=>$report=$this->input->post('report')
    );
    $this->load->model('patient_model');
    $this->patient_model->insertReport($data);
}
于 2013-01-23T18:34:19.610 回答