![]() |
Pagination for table with mysql data - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Pagination for table with mysql data (/showthread.php?tid=50722) |
Pagination for table with mysql data - El Forum - 04-05-2012 [eluser]targeting[/eluser] Hello! I have question about pagination for table. I have loaded table : $datatable = $this->site_model->get_query_table() and I need in $config['total_rows'] to count rows from datatable. A have already the table, only need the pagination for that. Please help! Thanks! Pagination for table with mysql data - El Forum - 04-05-2012 [eluser]Samus[/eluser] [quote author="targeting" date="1333651723"]Hello! I have question about pagination for table. I have loaded table : $datatable = $this->site_model->get_query_table() and I need in $config['total_rows'] to count rows from datatable. A have already the table, only need the pagination for that. Please help! Thanks! [/quote] Code: $config['total_rows'] = $this->db->count_all('my_table'); Pagination for table with mysql data - El Forum - 04-05-2012 [eluser]targeting[/eluser] Thank for quick reply! Actualy I have a data in table from mysql. My question is how count the rows from table which have the data? Pagination for table with mysql data - El Forum - 04-05-2012 [eluser]Samus[/eluser] [quote author="targeting" date="1333657149"]Thank for quick reply! Actualy I have a data in table from mysql. My question is how count the rows from table which have the data? [/quote] sorry you have to be abit more specific. if you mean you have a query and you want to count how many results are in that query. just use num_rows(); Pagination for table with mysql data - El Forum - 04-05-2012 [eluser]targeting[/eluser] Here is the part of the code: $datatable = $this->site_model->get_query_table($convertdate,$replacedtype); $data1['table'] = '<table id="myTable" class="tablesorter" > <thead><tr><th>Server</th><th>Media_Server</th><th width="220px">Server_Status</th><th width="50px">Files</th></tr></thead><tbody>'; for ($i = 0; $i < count($datatable); $i++) { $server = $datatable[$i]->Server; $mediaserver = $datatable[$i]->Domain_Backup_Server; $files= $datatable[$i]-> Files; $jobname= $datatable[$i]-> Job_Name; $data1['table'] .= '<tr >td>'.$server.'</td><td>'.$mediaserver.'</td><td>'.$replacedtype.'</td><td><a target="_blank" href="'.$files.'">'.$jobname.'</a></td></tr>'; } $data1['table'] .= '</tbody></table>'; $config['base_url'] = 'http://xyz'; $config['total_rows'] = count($datatable); print_r( $config['total_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); So I need counting the rows from table "$data['table']" and not from mysql, because data from mysql is already in table |