|
本帖最后由 东城︶ㄣLee 于 2012-3-28 22:55 编辑
$sql语句中的$data['search_type']和$data['spell']是从表单中提交得来的。点击分页链接时,程序会回到这段,而这个过程是没有表单提交过程的,此时的$data['search_type']和$data['spell']都未定义,致使程序运行不通过。看了论坛上一些分页的帖子,都是不传参数的,求高人提供解决方法。
PHP复制代码
$sql = "SELECT words.spell,words.class_abbr,words.meaning_cn FROM words WHERE id in (SELECT word_affix.word_id FROM word_affix WHERE word_affix.affix_id = (SELECT affixes.id FROM affixes WHERE (affixes.class=".$data['search_type']." AND affixes.name = '".$data['spell']."'))) ";
$data['word_affix'] = $this->words_model->get_words_by_affix($sql);
if (empty($data['word_affix']))
{
$data['page_title'] = 'Affix Not Found!';
$this->load->view('templates/header', $data);
$this->load->view('words/query', $data);
}else{
$limit = 10;
//每页显示数目
$config['base_url'] = base_url ().'/index.php/words/query_pagina';
//base_url可以防止换域名代码错误。
//获得总数。
$config['total_rows'] = count($data['word_affix']);
$config['per_page'] = $limit;
$config['first_link'] = 'Start';
$config['last_link'] = 'End';
$config['num_links'] = 10;
//$config['uri_segment'] = 3; //url segment max number
//上面是自定义文字以及左右的连接数
$this->pagination->initialize($config);
//初始化配置
$data['limit']=$limit;
$data['offset']=$offset;
$data['pagination']=$this->pagination->create_links();
//通过数组传递参数
$data['word_affix_array'] = $this->words_model->get_words_by_affix_pagina($sql, $limit, $offset);
$data['page_title'] = 'EM World';
$this->load->view('templates/header', $data);
$this->load->view('words/querypagina', $data);
}
复制代码
|
|