Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Model Code
- //=============================================
- class Countries extends CI_Model
- {
- public function __construct() {
- parent::__construct();
- }
- public function record_count() {
- return $this->db->count_all("Country");
- }
- public function fetch_countries($limit, $start) {
- /*
- $this->db->limit($limit, $start);
- $this->db->select('*');
- $this->db->from('Country');
- $this->db->where('status', 'Active');
- $query = $this->db->get();
- */
- $this->db->limit($limit, $start);
- $query = $this->db->get("Country");
- if ($query->num_rows() > 0) {
- foreach ($query->result() as $row) {
- $data[] = $row;
- }
- return $data;
- }
- return false;
- }
- }
- ?>
- //=============================================
- //Controller Code
- //=============================================
- <?php
- public function blog()
- {
- $config = array();
- $config["base_url"] = base_url() . "/user/blog/";
- $config["total_rows"] = $this->blog_model->record_count();
- $config["per_page"] = 10;
- $config["uri_segment"] = 3;
- $config['full_tag_open'] = '<ul class="page-numbers">';
- $config['full_tag_close'] = '</ul>';
- $config['attributes'] = ['class' => 'page-number'];
- $config['first_link'] = false;
- $config['last_link'] = false;
- $config['first_tag_open'] = '<li>';
- $config['first_tag_close'] = '</li>';
- $config['prev_link'] = '<span class="ti-arrow-left"></span>';
- $config['prev_tag_open'] = '<li>';
- $config['prev_tag_close'] = '</li>';
- $config['next_link'] = '<span class="ti-arrow-right"></span>';
- $config['next_tag_open'] = '<li>';
- $config['next_tag_close'] = '</li>';
- $config['last_tag_open'] = '<li>';
- $config['last_tag_close'] = '</li>';
- $config['cur_tag_open'] = '<li><span class="page-number current">';
- $config['cur_tag_close'] = '</span></li>';
- $config['num_tag_open'] = '<li>';
- $config['num_tag_close'] = '</li>';
- $this->pagination->initialize($config);
- if($this->uri->segment(3)){
- $page = ($this->uri->segment(3)) ;
- }
- else{
- $page = 0;
- }
- $data["blogs"] = $this->blog_model->fetch_countries($config["per_page"], $page);
- $data["links"] = $this->pagination->create_links();
- // View data according to array.
- $this->load->view("Blog", $data);
- }
- ?>
- //=============================================
- //View Code
- //=============================================
- <?php
- foreach($blogs as $data) {
- echo $data->Name . " - " . $data->Continent . "<br>";
- }
- ?>
- <p><?php echo $links; ?></p>
Add Comment
Please, Sign In to add comment