Controller:
<?php
class Site extends CI_Controller {
public function index() {
$this->load->library('pagination');
$this->load->library('table');
$config['base_url'] = base_url().'site/index';
$config['total_rows'] = $this->db->get('userlogin')->num_rows();
$data['total'] = $this->db->get('userlogin')->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);
$data['records'] = $this->db->get('userlogin', $config['per_page'], $this->uri->segment(3));
$this->load->view('site_view', $data);
}
}
------------------------------------------
views:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<style type="text/css" media="screen">
#container {
width: 600px;
margin: auto;
font-family: helvetica, arial;
}
table {
width: 600px;
margin-bottom: 10px;
}
td {
border-right: 1px solid #aaaaaa;
padding: 1em;
}
td:last-child {
border-right: none;
}
th {
text-align: left;
padding-left: 1em;
background: #cac9c9;
border-bottom: 1px solid white;
border-right: 1px solid #aaaaaa;
}
#pagination a, #pagination strong {
background: #e3e3e3;
padding: 4px 7px;
text-decoration: none;
border: 1px solid #cac9c9;
color: #292929;
font-size: 13px;
}
#pagination strong, #pagination a:hover {
font-weight: normal;
background: #cac9c9;
}
</style>
</head>
<body>
<div id="container">
<h1>Super Pagination with CodeIgniter</h1>
<?php echo $this->table->generate($records); ?>
<?php echo $this->pagination->create_links(); ?>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$('tr:odd').css('background', '#e3e3e3');
</script>
</body>
</html>
----------------------------------------
Output
0 comments:
Post a Comment