|
本帖最后由 zjsjkyjyd 于 2010-3-3 23:15 编辑
模型:<?php
class BgglModel extends Model {
function BgglModel() {
parent::Model();
}
function insert() {
$data=array(
'bgbh'=>$this->input->post('bgbh'),
'jyrq'=>$this->input->post('jyrq'),
'sbmc'=>$this->input->post('sbmc'),
'wtdw'=>$this->input->post('wtdw'),
'gcmc'=>$this->input->post('gcmc'),
'jbry'=>$this->input->post('jbry'),
'sfje'=>$this->input->post('sfje'),
'fpqk'=>$this->input->post('fpqk'),
'ssdq'=>$this->input->post('ssdq'),
'khxm'=>$this->input->post('khxm'),
'lxdh'=>$this->input->post('lxdh'),
'bz'=>$this->input->post('bz'),
'crtime'=>time(),
);
$this->db->insert('bggl',$data);
}
function inquiry() {
$arr=array(
'bgbh'=>$this->input->xss_clean($this->input->post('bgbh')),
'jyrq'=>$this->input->xss_clean($this->input->post('jyrq')),
'sbmc'=>$this->input->xss_clean($this->input->post('sbmc')),
'wtdw'=>$this->input->xss_clean($this->input->post('wtdw')),
'gcmc'=>$this->input->xss_clean($this->input->post('gcmc')),
'jbry'=>$this->input->xss_clean($this->input->post('jbry')),
'sfje'=>$this->input->xss_clean($this->input->post('sfje')),
'fpqk'=>$this->input->xss_clean($this->input->post('fpqk')),
'ssdq'=>$this->input->xss_clean($this->input->post('ssdq')),
);
$query=$this->db->get_where('bggl',$arr);
return $query;
}
}
控制器:
<?php
class Bggl extends Controller {
function bggl() {
parent::Controller();
// $this->load->scaffolding('bggl');
$this->form_validation->set_message('required', '%s不能为空.');
$this->form_validation->set_message('max_length', '%s不能超过%s个字符.');
$this->form_validation->set_message('min_length', '%s不能少于%s个字符.');
}
function index() {
$this->load->view('header');
$this->load->view('bgdj');
}
function bgdj() {
$this->form_validation->set_rules('bgbh','报告编号','trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('jyrq','检验日期','trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('sbmc','设备名称','trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('wtdw','委托单位','trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('gcmc','工程名称','trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('jbry','经办人员','trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('sfje','收费经额','trim|required|max_length[5]|xss_clean');
$this->form_validation->set_rules('fpqk','费票情况','trim|required|xss_clean');
$this->form_validation->set_rules('ssdq','所属地区','trim|required|xss_clean');
$this->form_validation->set_rules('khxm','客户姓名','trim|xss_clean');
$this->form_validation->set_rules('lxdh','联系电话','trim|xss_clean');
$this->form_validation->set_rules('bz','备注','trim|xss_clean');
if ($this->form_validation->run() == FALSE) {
$this->load->view('header');
$this->load->view('bgdj');
}
else {
$this->load->model('bgglModel');
$this->bgglModel->insert();
$this->load->view('header');
$this->load->view('bgdj');
}
}
function bgcx() {
if($this->input->post('bgcxsub')==FALSE) {
$this->load->view('header');
$this->load->view('bgcx');
}
else {
$this->load->model('bgglModel');
$data['query']=$this->bgglModel->inquiry();
$this->load->view('header');
$this->load->view('bgcx',$data);
}
}
}
视图:
<div id="main">
<?php echo form_open('bggl/bgcx');
$tbdata=array(
array("报告编号",form_input('bgbh',set_value('bgbh')),form_error('bgbh')),
array("检验日期",form_input('jyrq',set_value('jyrq')),form_error('jyrq')),
array("设备名称",form_input('sbmc',set_value('sbmc')),form_error('sbmc')),
array("委托单位",form_input('wtdw',set_value('wtdw')),form_error('wtdw')),
array("工程名称",form_input('gcmc',set_value('gcmc')),form_error('gcmc')),
array("经办人员",form_input('jbry',set_value('jbry')),form_error('jbry')),
array("收费金额",form_input('sfje',set_value('sfje')),form_error('sfje')),
array("费票情况",form_input('fpqk',set_value('fpqk')),form_error('fpqk')),
array("所属地区",form_input('ssdq',set_value('ssdq')),form_error('ssdq')),
array("",form_submit('bgcxsub','查询'))
);
echo $this->table->generate($tbdata);
?>
</form>
<table border="1">
<tr>
<th>报告编号</th><th>检验日期</th><th>设备名称</th><th>委托单位</th><th>工程名称</th>
</tr>
<?php foreach($query->result as $row) : ?>
<tr>
<td><?=$row->bgbh?></td>
<td><?=$row->jyrq?></td>
<td><?=$row->sbmc?> </td>
<td><?=$row->wtdw?> </td>
<td><?$row->gcmc?> </td>
</tr>
<?php endforeach; ?>
</table>
</div>
以上为代码,以下为出错信息:
进入查询页面未提交时出现
进入查询页面示提交时出现
提交后出现
提交后出现 |
|