Error with pagination and codeigniter

3

Clicking on the page link returns a NOT FOUND.

    <div class="scroll">
<table class="table table-hover" id="myTable">
    <thead>
        <tr>
            <th><b>Nome</b></th>
            <th><b>Email</b></th>
            <td><b>Telefone</b></td>
            <td><b>Cidade</b></td>
            <td><b>PR</b></td>
        </tr>
    </thead>

    <tbody>
    <?php foreach ($results as $data) : ?>
        <td><?= $data->nomeCliente ?></td>
        <td><?= $data->emailCliente ?></td>
        <td><?= $data->telefoneCliente ?></td>
        <td><?= $data->cidadeCliente ?></td>
        <td><?= $data->estadoCliente ?></td>            
        <td>
            <a ><i class="glyphicon glyphicon-trash" title="Apagar" onclick="modalDelete()"></i></a>
        </td>

        <td>
            <a href="index.php"><i class="glyphicon glyphicon-edit" title="Editar".></i></a>
        </td>

        <td>
           <a href="index.php"><i class="glyphicon glyphicon-eye-open" title="Visualizar"></i></a>
        </td>
    </tr>
<?php endforeach ?>
</tbody>
</table>
<center>
    <ul class="pagination">
        <li><a><?php echo $links; ?></a></li>
    <ul>
</center>
</div>

Here's the CONTROLLER

public function consultaClientes() {
    $this->output->enable_profiler(TRUE);
    $this->load->model("Cliente/Clientes_Model");
    $config["base_url"] = base_url('index.php/Cliente/');
    $config["total_rows"] = $this->Clientes_Model->record_count();
    $config["per_page"] = 5;
    $config['use_page_numbers'] = TRUE;
    $config["uri_segment"] = 3;
    $choice = $config["total_rows"] / $config["per_page"];
    $config["num_links"] = round($choice);

    $this->pagination->initialize($config);

    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
    $data["results"] = $this->Clientes_Model
        ->fetch_countries($config["per_page"], $page);
    $data["links"] = $this->pagination->create_links();

    $this->load->view("menu");
    $this->load->view("Cliente/Clientes", $data);
}

Here the MODEL

public function record_count() {
        return $this->db->count_all("cliente");
    }


    public function fetch_countries($limit, $start) {
        $this->db->limit($limit, $start);
        $query = $this->db->get("cliente");

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
        return false;
    }

A route is still configured.

$route['Cliente'] = 'Cliente/Clientes/consultaClientes';
    
asked by anonymous 20.08.2017 / 22:43

1 answer

0

It looks like an incorrect routing. When the user types:

www.seu-site.com.br/cliente/

It will (virtually) be pushed to:

www.seu-site.com.br/cliente/clientes/consultaClientes

That is, for method clientes() of class Cliente , passing as parameters the string consultaCliente . However, method clientes($string) does not exist in your Cliente class, so the static string 'consultaClientes' does not make sense either.

I think that if the intent is to define the default behavior of class Cliente clients' view, it should exclude routing and implement the actions within the method named index() in the class. This is the method that is automatically invoked when requesting something like this:

www.seu-site.com.br/cliente

    
22.08.2017 / 14:07