Hallo Ich habe Seitennummerierung in PHP-Code implementiert Aber es funktioniert nicht, während Sie auf die Seitenumbruch Links klicken.Es zeigt die gleichen Daten für alle Seiten.Hier ist der Code.So erstellen Sie die Seitennummerierung im Codegeigner
Controller:
class Testimonial extends CI_Controller {
function __construct() {
parent::__construct();
//here we will autoload the pagination library
$this->load->library('pagination');
}
public function index()
{
$this->load->model('testimonial_model');
$config = array();
$config["base_url"] = base_url('testimonial/index');
$config['total_rows'] = $this->db->count_all("testimonials");//here we will count all the data from the table
$config['per_page'] = 6;//number of data to be shown on single page
$config["uri_segment"] = 2;
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data["records2"] = $this->testimonial_model->get_all_testimonials($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();//create the link for pagination
$data['mainpage'] = "testimonial";
$this->load->view('templates/template',$data);
}
Modell:
class Testimonial_model extends CI_Model
{
function get_all_testimonials($limit, $start)
{
$this->db->limit($limit, $start);
$this->db->select('T.*');
$this->db->from('testimonials AS T');
$this->db->where(array('T.status'=>1));
$q = $this->db->get();
if($q->num_rows()>0)
{
return $q->result();
}
else
{
return false;
}
}
}
Ausblick:
<div class="pagination"><?php echo $links; ?></div>
Wer das mir helfen kann, aus – user6728960
versuchen mit uri segmant 3: $ page = ($ this-> uri-> Segment (3))? $ this-> uri-> Segment (3): 0; – Rijin
@Rijin Vielen Dank seine Arbeit – user6728960