Pagination problem, getting a blank page.

I've been trying everything to get this pagination system to work, but everytime it comes up with a blank page, NOTHING is showing up and I've run outa options, can anyone see something that I cant?

class Page extends Controller {

    function Page()
    function index()

    function view()
           $per_page = 10;
           $total = $this->posts_model->count_posts();
           $data['blogs'] = $this->posts_model->get_posts($per_page, $this->uri->segment(3));

           $base_url = site_url('page/view');
           $config['base_url'] = $base_url;
           $config['total_rows'] = $total;
           $config['per_page'] = $per_page;
           $config['uri_segment'] = '3';

           $this->load->view('page_view', $data);




class Blog_model extends Model {

function Blog_model()

function get_posts($limit = NULL, $offset = NULL)
  $this->db->limit($limit, $offset);
  return $this->db->get('Blogs');

function count_posts()
  return $this->db->count_all_results('Blogs');


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
&lt;html &gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;

Blog Posts
<br />
foreach ($blogs->results() as $blog):
echo $blog->Title, '
echo $blog->Body_content;

echo $this->pagination->create_links();


Any help would be greatly appreciated guys, I'm at my wits end.

The index() function is empty, does it work if you access ?

You should enable error reporting in index.php to see if you get any errors:

You should also omit the closing tag: (user guide)
Quote:The PHP closing tag on a PHP document ?&gt; is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages. For this reason, all PHP files should OMIT the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root. This allows you to still identify a file as being complete and not truncated.

Hmmm, I seem to be getting an error with the Pagination Library...

Parse error: syntax error, unexpected '&' in /home/content/18/4876118/html/dev/system/libraries/Pagination.php on line 188

Fixed, for some reason my pagination library has some $gt; instead of > symbols. Weird.

Now it's giving me some funky things, the 1 and the 2 link work fine, but 3 is linking to 4 and it says 4 is the max pages, but if I manually type in 5 I get more results.

Strange if I must say so.

In your model's count_posts() function, $this->db->count_all_results() is not a function. $this->db->count_all('Blogs'); would be the appropriate use.

Also not sure if it matters now, but in your controller you've called "Blog_model", but you're calling functions from "posts_model". Perhaps you've autoloaded it, or fixed it in your live version. But it looks out of place.

And on another random note, what's up with the session_start() up top?

I had the session start there for some reason, I can't remember now. But I got things working good, the only problem it seems is that the Pagination doesn't increment by 1 but by 2. for example, Page 1 is the default view, page 2 is 2, page 3 is 4, page 4 is 6, page 5 is 8. Everything seems to comeout ok none the less. But I just found it akward that it would do that.

I don't know what you're experiencing, but maybe you're a bit confused on the way the Pagination class works. By default, the URL numbers generated are the beginning result count, with that number + results per page being the end result to return.

For instance, say you have a blog with XXX posts, and you want to show 10 per page. If you visited, you'd see 1-10. If you went to, you'd see 11-20 (or whatever exact number you set up). would show you 121-130, etc etc.

The class uses the beginning item count as a "page" number, instead of normal page numbers (eg. blog/page-3).

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.