1

状況

Codeigniter ページネーションを実装したい検索結果ページにリダイレクトする検索フォームがあります。制限が機能していません。そのため、私の代わりにすべての結果が表示されます$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'] . ", &nbsp;" ; ?>
        </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 />
4

1 に答える 1