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>
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:
In view file:
If I understand you correctly
I don’t see where you either
echoor 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 :and it produced :
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
postsso you can display it on the page. For example$posts["pagination"] = $this->pagination->create_links();And then display it on the page by usingecho $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…