ci分页下拉菜单
<?php
//view 视图
<div class="info_box" style="width:1100px;text-align:center;">查询:
<div class="detail_info"><br /><form name="search" id="search" method="POST" action="<?php echo $baseurl;?>admin/goods/searchclient/">
<label>
<select name="method" id="method">
<option value="0"> 按联系人 </option>
<option value="1"> 按公司名称 </option>
</select>
</label> 输入关键字: <input type="text" name="keyword" id="keyword"/> <input type="Submit" class="button" value="立即查询" onclick="return check()"/></form>
</div></div>
//controller
//控制器
function getlist()
{
$method=$this->input->post("method");
if($method==0) {
//按名称查询
$condition=$this->input->post("keyword");
$data['all_goods'] =$this->admin_model->post_a_goods($condition);
}
if($method==1) {
//按序号查询
$condition=$this->input->post("keyword");
$data['all_goods'] =$this->admin_model->post_b_goods($condition);
}
$data['baseurl']=site_url();
$this->load->view('admin/goods.html',$data);
}
//model
//获取查询新闻分页
function post_a_goods($id)
{
$this->db->like('name',$id);
$this->db->from('news');
$this->db->order_by('id','desc');
$mycount = $this->db->count_all_results();
$this->load->library('pagination');
$config['base_url'] = site_url('admin/goods/getlista') . "/" . $id;
$config['total_rows'] = $mycount;
$config['per_page'] = '10';
$config['num_links'] = '6';
$config['uri_segment'] = 5;
$config['full_tag_open'] = '<div class="pagination">';
$config['full_tag_close'] = '</div>';
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$this->pagination->initialize($config);
$this->db->select('*');
$this->db->like('name',$id);
$this->db->order_by('id','desc');
$query=$this->db->get('news',$config['per_page'],$this->uri->segment(5));
return $query;
}
function post_b_goods($id)
{
$this->db->where('id',$id);
$this->db->from('news');
$this->db->order_by('id','desc');
$mycount = $this->db->count_all_results();
$this->load->library('pagination');
$config['base_url'] = site_url('admin/goods/getlistb') . "/" . $id;
$config['total_rows'] = $mycount;
$config['per_page'] = '10';
$config['num_links'] = '6';
$config['uri_segment'] = 5;
$config['full_tag_open'] = '<div class="pagination">';
$config['full_tag_close'] = '</div>';
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$this->pagination->initialize($config);
$this->db->select('*');
$this->db->where('id',$id);
$this->db->order_by('id','desc');
$query=$this->db->get('news',$config['per_page'],$this->uri->segment(5));
return $query;
}
//controller
//控制器
function getlista($sql)
{
$data['baseurl']=site_url();
$data['news'] = $this->News_model->post_a_goods($sql);
$this->load->view('admin/goods.html',$data);
}
function getlistb($sql)
{
$data['baseurl']=site_url();
$data['news'] = $this->News_model->post_b_goods($sql);
$this->load->view('admin/goods.html',$data);
}
?>
<TD colspan="7" vAlign=top ><?php echo $this->pagination->create_links();?></TD> |