Skip to Content
Codeigniter Public Articles Listing
codeigniter code / August 5, 2018

public Articles Listing in Codeigniter

Step 1 :- created view in articles_list.php
<?php include (‘public_header.php’);?>
<div class=”container”>
<h1>All Articles</h1>
<table class=”table”>
<td>Sr No.</td>
<td>Article Title</td>
<td>Published On</td>
<?php if(count($articles)):?>
<?php $count=$this->uri->segment(3,0);?>
<?php foreach($articles as $article ):?>
<td><?= ++$count?></td>
<td><?= $article->title?></td>
<td><?= “Date” ?></td>
<?php endforeach;?>

<?php else: ?>
<td colspan=”3″> No Records Found.</td>
<?php endif;?>
<?= $this->pagination->create_links()?>

<?php include (‘public_footer.php’);?>s

step 2: created model two function here

public function all_articles_list($limit,$offset)
return $query->result();

public function count_all_articles()
return $query->num_rows();

step 3: created controller user.php

class User extends MY_Controller
public function index()
‘base_url’ => base_url(‘user/index’),
‘per_page’  => 5,
‘total_row’ => $this->articles->count_all_articles(),
‘full_tag_open’ => “<ul class=’pagination’>”,
‘full_tag_close’=> “</ul>”,
‘first_tag_opne’ => “<li>”,
‘first_tag_close’=> “</li>”,
// ‘first_link’ => “<li>”
// ‘last_link’ => “</li>”
‘last_tag_opne’ => “<li>”,
‘last_tag_close’ => “</li>”,
‘next_tag_opne’ => “<li>”,
‘next_tag_close’ => “</li>”,
‘pre_tag_open’  => “<li>”,
‘pre_tag_close’ => “</li>”,
‘num_tag_open’  => ‘<li>’,
‘num_tag_close’ => ‘</li>’,
‘cur_tag_open’  => “<li class=’active’><a>”,
‘cur_tag_close’ => ‘</a></li>’,


No comments yet, take the initiative.

Leave a Reply

Your email address will not be published.

PHPCODE © 2023