情况
我有一个重定向到我想要实现笨分页一个SearchResult所页面searchform。 我的极限是行不通的。 因此,所有的结果显示,而不是我的$limit = 4;
这里是我的控制器代码:
function searchresults()
{
$this->breadcrumbs->page = array('link'=> base_url().'home/search' ,'title' => 'Bedrijven Zoeken' );
$this->breadcrumbs->method = array('link'=> base_url().'home/searchresults' ,'title' => 'Zoekresultaten' );
$data['breadcrumbs'] = $this->breadcrumbs->get();
$match = $this->input->post('search');
if(strlen($this->input->post('cookie')) > 0){ $match2 = $this->input->post('cookie'); } else{ $match2 = '9101'; }
$data['query'] = $this->bedrijven_model->get_search($match, $match2);
$limit = 4;
$this->load->library('pagination');
$config['base_url'] = base_url().'home/searchresults/';
$config['total_rows'] = count($data['query']);
$config['per_page'] = $limit;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['links'] = $this->pagination->create_links();
$this->load->view('views/header');
$this->load->view('views/searchresults', $data);
$this->load->view('views/footer');
}
题
可能是什么问题呢? 我缺少的东西吗?
编辑
我仍然无法得到它的工作。 这是我到目前为止所。
控制器:
function searchresults()
{
$this->breadcrumbs->page = array('link'=> base_url().'home/search' ,'title' => 'Bedrijven Zoeken' );
$this->breadcrumbs->method = array('link'=> base_url().'home/searchresults' ,'title' => 'Zoekresultaten' );
$data['breadcrumbs'] = $this->breadcrumbs->get();
$match = $this->input->post('search');
if(strlen($this->input->post('cookie')) > 0){ $match2 = $this->input->post('cookie'); } else{ $match2 = '9101'; }
$this->load->library('pagination');
$config['base_url'] = base_url().'home/searchresults/';
$config['per_page'] = 4;
$this->pagination->initialize($config);
$data['links'] = $this->pagination->create_links();
//$data['query'] = $this->bedrijven_model->get_search($match, $match2, 2147483647, 0); /*large number as limit to retrieve all the rows*/
$data['query_curr'] = $this->bedrijven_model->get_search($match, $match2, $config['per_page'], $this->uri->segment(3) );
$this->load->view('views/header');
$this->load->view('views/searchresults', $data);
$this->load->view('views/footer');
}
模型:
function get_search($match, $match2, $limit, $offset)
{
$this->db->limit($limit, $offset);
//rest of the code
}
我的观点:
<?php foreach($query_curr as $item):?>
<br/>
<div class="logo1">
<a href="<?php echo base_url()?>bedrijven/<?= $item['idbedrijven'] ?>"><img src="http://i.ebayimg.com/t/Aluminum-Body-Violin-or-Cello-Makers-Compass-Draw-Shave-Plane-Good-Shape-/00/s/NDYwWDU1MQ==/$(KGrHqJ,!hYF!sl)RwymBQiLq5Cn4Q~~60_35.JPG"></a>
</div>
<a href="<?php echo base_url()?>bedrijven/<?= $item['idbedrijven'] ?>"><h3><?= $item['Bedrijfsnaam'] ?></h3></a>
<p>
<b>Categorie:</b>
<?php echo "" . $item['Categorie'] . ", " ; ?>
</p>
<small>
<p><b><?php echo $item['Email'] ?></b></p>
<p><b>Postcode:</b> <?php echo $item['Postcode'] ?></p>
<p><b>Plaats:</b> <?php echo $item['Plaats'] ?></p>
<p><b>Tags:</b></p>
<p><?php echo $item['Profiel'] ?></p>
</small>
<br/><hr/>
<?php endforeach;?>
<br/>
<?= $this->pagination->create_links(); ?>
<br />
<br />