Welcome Guest, Not a member yet? Register   Sign In
AJAX Pagination
#1

[eluser]Johan Michel[/eluser]
Hi guys,

I'm just new to this forum, and honestly also CodeIgniter (used Smarty and my own frameworks before).

[off-topic]
First I think it's polite to introduce myself a bit, I'm Johan, 27 years old, not having a special expertise, more a general internet knowledge (in SEO, Adwords, Design, Programming (although I suck at it Smile). I'm an autist (asperger) as I think 5 to 10% of people working hard-code in the IT are :o)
I'm from The Netherlands, small village... well thats it Smile
[/off-topic]

I'm having problems with the plugin AJAX Pagination (http://codeigniter.com/wiki/AJAX_Paginat...n_Library/).

Yesterday I inserted in my structure.

Ajax_pagination.php in system/libraries/
my_data_page.php in system/application/controllers/
xhtml code inside a function (in system/application/controllers/welcome.php) which displays the books (i have a book comparison site).

When I tried to add the class My_data_page as in $d = new My_data_page(); it gave an error that it can't find the class (while NuSphere PHPED found the class). So in the end I moved my_data_page.php to welcome.php, now it does recognize the class, but I get these errors:

---
A PHP Error was encountered

Severity: Notice

Message: Undefined property: My_data_page::$common_model

Filename: libraries/Loader.php

Line Number: 1035

Fatal error: Call to a member function _assign_libraries() on a non-object in /home/vergelij/public_html/system/libraries/Loader.php on line 1035
---

When I remove $this->load->library('table'); this error goes away but I get a similar error but than a problem with the database.

Can anyone help me out with this, I would so much appreciate it.

Yours, Johan
#2

[eluser]Johan Michel[/eluser]
Well I solved some stuff now, but I keep getting weird errors. Trying to fix them now.
#3

[eluser]Johan Michel[/eluser]
I solved most of the issues, the files contain quite a lot of errors. Here is a small improved version for people who are going to use it in the future:

Code:
<? class My_data_page extends Controller{
    function My_data_page(){
       parent::Controller();
       $this->load->library('table');
       $this->load->helper('html');
       $this->load->library('Ajax_pagination');
    }
    function index(){
        $data['makeColumns'] = $this->makeColumns();
        $data['getTotalData'] = $this->getTotalData();
        $data['perPage'] = $this->perPage();
        $this->load->view('my_data_page', $data);
    }
    //Pull 'name' field records from table 'contact'
    function getData(){
        
        $page = $this->input->post('page'); //Look at $config['postVar']
        if(!$page):
        $offset = 0;
        else:
        $offset = $page;
        endif;
        
        $sql = "SELECT * FROM foo LIMIT ".$offset.", ".$this->perPage();
        $q = $this->db->query($sql);
        return $q->result();
    }
    function getTotalData(){
      $sql = "SELECT * FROM foo";
      $q = $this->db->query($sql);
      return $q->num_rows();
    }
    
    function perPage(){
         return 10; //define total records per page
      }
    
    //Generate table from array
    function makeColumns(){
         $foo = $this->getData();

         foreach($books as $row):
             $data[] = $row->isbn;
             $data[] = $row->title;
             $data[] = $row->link;
         endforeach;
         return  $this->table->make_columns($data, 6);
    }
}
?>
#4

[eluser]Johan Michel[/eluser]
Almost solved everything, for the newbies like me please keep in mind how important capitals or non-capitals are in files.

One problem to fix, I could use some help because I have no clue...

On the page when I click on Last or on [2] or [3] I get a 404 error. Please see http://www.vergelijkboek.nl/index.php/My_data_page, can anyone help me with this?




Theme © iAndrew 2016 - Forum software by © MyBB