Author Topic: CoDE igneter pagination help  (Read 1889 times)

0 Members and 1 Guest are viewing this topic.

Offline hamzaTopic starter

  • Enthusiast
  • Posts: 299
    • View Profile
CoDE igneter pagination help
« on: November 21, 2008, 12:51:09 PM »
Please tell me how i use pagination in short paging to get 20 records per page
what i have done is all shown below config , model , controller , n actuall page
all code is below
thanks if any help is replies


pagination.php config file
=======================
[/code]
<?php
$config['base_url'] = 'http://localhost/working/CodeIgniter_1.6.3/index.php/Admin/users/';
$config['total_rows'] = '300';
$config['per_page'] = '20';
?>
[/code]

controller ‘Admin’ have function
====================
Code: [Select]
function users() {
   
        $data['userdata']    = $this->Madmin->getAllUsers();       
           
        $data['usersStatus'] = $this->Madmin->getAllUsersStatus();

        $data['title']='Users Lists';
        $data['heading']='Users List ';
        $this->load->view('admin/users',$data);
   
    }


view name is : users
====================
Code: [Select]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $title;?></title>
</head>

<body>
<?php    $data_ADD = array( 'src'  => 'asset/newobject.gif' ,'title'=>'Add User' 'border' => '0');?>
<?php    $data1 = array( 'src'  => 'asset/non.gif' ,'title'=>'Delete User' 'border' => '0');?>
<?php    $data_EDIT = array( 'src'  => 'asset/edit.gif''title'=>'Edit User' 'border' => '0');?>

<?php echo $this->load->view('admin/header'); ?>

<?php echo br().'<hr>'?>
<?php
echo anchor('User/register',img($data_ADD).'Add New'); echo br();
echo 
'Total registered Users ::&nbsp; '.$this->db->count_all('register');
echo 
br();


if( empty(
$userdata) ) { //if no recored found
echo $msg 'No Recored Found';

}else { 
     
$this->table->add_row('<b>ID''<b>NAME' '<b>COUNTRY''<b>EMAIL','<b>Status','<b>Actions');
//$this->table->add_row(  anchor('User/register',img($data_ADD)) );

$num=1;
$statusCount=0;
foreach(
$userdata as $records) {
        
$color = ($num%2==0)? '#00CCCC''#00CCCC';
echo 
'<p style=background-color:'.$color.'>';


    
$status = ( $usersStatus[$statusCount]=='yes')? 'Active' :'InActive';
    
$this->table->add_row$records['id'] , $records['name'] , $records['country'] , $records['email'] , $status ,anchor('Admin/delete/'.$records['id'].'',img($data1)) , anchor('Admin/editUser/'.$records['id'],img($data_EDIT)) );             
    


echo 
'</p>';
$num++;
$statusCount++;
}
echo 
$this->table->generate();

}
//if end

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

</body>
</html>

And the model i have is this =>  ‘Madmin’
Code: [Select]
function getAllUsers() {
        $dbData = array();
          $this->db->select('*');
        $this->db->limit('');
        $query = $this->db->get('register');       
       
        foreach( $query->result_array() as $records ) {
          $dbData[] = $records;
        }
        return $dbData;
    }
   
    function getAllUsersStatus() {
        $dbData = array();
          $this->db->select('status');
        $query = $this->db->get('login');
       
        foreach( $query->result_array() as $records ) {
          $dbData[] = $records;
        }
        return $dbData;
    }

Offline Maq

  • Global Moderator
  • 'Insane!'
  • *
  • Posts: 11,002
  • Gender: Male
    • View Profile
    • Top Ecigs Reviews
Re: CoDE igneter pagination help
« Reply #1 on: November 21, 2008, 01:40:22 PM »
Sure, read this.  Do you actually have a problem or error?
Electronic Cigarette Reviews - Smoking alternatives, find YOUR ecig!
ini_set ("display_errors""1");
error_reporting(E_ALL);

Offline awpti

  • Enthusiast
  • Posts: 453
  • Gender: Male
    • View Profile
    • GoMySQL - DBA Blog and Tutorials
Re: CodeIgniter pagination help
« Reply #2 on: November 24, 2008, 06:24:33 PM »
Uh, better yet.

Read this - the proper documentation for the CI Framework.

The pagination content laid out on phpfreaks.com will not help in with this framework.

All of your questions can be answered there regarding functionality.
Server: Apache 2.2.3 - PHP 5.2.17, MySQL 5.0, 5.1, 5.5 and 6.0 - 2x Quad Core Xeon 5620 w/ 16G Mem
GeekLAN - Ignited Jobs - LAMP Tips

10+ Years of hobby PHP Development and Database Design.

Offline Maq

  • Global Moderator
  • 'Insane!'
  • *
  • Posts: 11,002
  • Gender: Male
    • View Profile
    • Top Ecigs Reviews
Re: CoDE igneter pagination help
« Reply #3 on: November 25, 2008, 09:57:08 AM »
Uh, better yet.

Read this - the proper documentation for the CI Framework.

The pagination content laid out on phpfreaks.com will not help in with this framework.

All of your questions can be answered there regarding functionality.

 :D
Electronic Cigarette Reviews - Smoking alternatives, find YOUR ecig!
ini_set ("display_errors""1");
error_reporting(E_ALL);