Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4122162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:26:46+00:00 2026-05-20T23:26:46+00:00

I have done pagination with CodeIgniter and it is listing Results from my database

  • 0

I have done pagination with CodeIgniter and it is listing Results from my database as, Title, Content, Price, and postid. I was wondering how do I make the content (title, content, price) that it is displaying show as links(

function index() 
    {
            $this->load->library('pagination');
            $this->load->library('table');

            $this->table->set_heading('postid', 'The Title', 'The Content', 'Price');

            $config['base_url'] = 'http://localhost/ganbaru/index.php/site/index';
            $config['total_rows'] = $this->db->get('posts')->num_rows();
            $config['per_page'] = 10;
            $config['num_links'] = 20;
            $config['full_tag_open'] = '<div id="pagination">';
            $config['full_tag_close'] = '</div>';

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

            $posts['records'] = $this->db->get('posts', $config['per_page'], $this->uri->segment(3));

            $this->load->view('site_view', $posts);
    }

Here is the view code

</head>
<body>  


<div id="container">
                    <h1>Super Pagination with CodeIgniter</h1>
                    <?php echo $this->table->generate($records); ?>
                    <?php echo $this->pagination->create_links(); ?>
            </div>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:26:47+00:00Added an answer on May 20, 2026 at 11:26 pm

    Update sorry did not quite understand

    I haven’t used the table library but you can create loop and just output the links by using something like:

    In Controller:

    $query = $this->db->get('posts', $config['per_page'], $this->uri->segment(3));
    $posts["records"] = $query->result_array();
    

    In view file:

    </head>
    <body>  
    <div id="container">
    <h1>Super Pagination with CodeIgniter</h1>
    <table>
    <?php foreach($records as $record) { ?>
    <tr>
    <td><a href="<?php echo site_url('myuri/' . $record["id"]); ?>"><?php echo $record["id"]; ?></a></td>
    <td><a href="<?php echo site_url('myuri/' . $record["id"]); ?>"><?php echo $record["title"]; ?></a></td>
    <td><a href="<?php echo site_url('myuri/' . $record["id"]); ?>"><?php echo $record["content"]; ?></a></td>
    </tr>
    <?php } ?>
    </table>
    <?php echo $this->pagination->create_links(); ?>
    </div>
    </body>
    </html>
    

    I haven’t tested this, and is a bit more ugly then your original code but will give you more direct control.>

    If I understand you correctly

    I don’t see where you either echo or store the results of $this->pagination->create_links();, this is what produces the pagination output from the library and what you will need to display to show the links. But as you pointed out you don’t know how to surround the output with tags. I tried the example from the user-guide which is :

    $this->load->library('pagination');
    
    $config['base_url'] = 'http://example.com/index.php/test/page/';
    $config['total_rows'] = '200';
    $config['per_page'] = '20'; 
    
    $this->pagination->initialize($config); 
    
    echo $this->pagination->create_links();
    

    and it produced :

    <strong>1</strong>
    <a href="http://example.com/index.php/test/page/20">2</a>
    <a href="http://example.com/index.php/test/page/40">3</a>
    <a href="http://example.com/index.php/test/page/20">&gt;</a>
    <a href="http://example.com/index.php/test/page/180">Last &rsaquo;</a>
    

    which does have the tags. So you should have a look at the example in the user-guide and maybe store the Pagination Output as a variable under the posts so you can display it on the page. For example $posts["pagination"] = $this->pagination->create_links(); And then display it on the page by using echo $pagination.

    The Documentation is at – http://codeigniter.com/user_guide/libraries/pagination.html – so you can have a quick read for all the options.

    Hope that helps…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have done a bit of research into this and it seems that the
I have done Java and JSP programming in the past, but I am new
I have done a bit of testing on this myself (During the server side
I have done some searches looking for information about how to do logging with
I have done a little Django development, but it has all been in a
I have done this: $ z() { echo 'hello world'; } How do I
I have done jQuery and Ajax, but I am not able to get the
I have done the following code in JavaScript to put focus on the particular
I thought this would have done it... $rowfetch = $DBS->{Row}->GetCharValue(meetdays); $rowfetch = /[-]/gi; printline($rowfetch);
I could have sworn i have done this somewhere - im using 2.0 right

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.