[eluser]srajibtechno[/eluser]
i am facing problem in CI pagination class...
here is my model: test_model.php
class Test_model extends Model
{
function Test_model()
{
parent::Model();
$this->load->database();
session_start();
}
function get_submenu($num,$offset,$id)
{
$this->db->select('*');
$this->db->from('inbook_special_phase_details');
$this->db->where('cat_id', $id);
$query = $this->db->get();
return $query;
}
function get_nrows($num,$offset,$id)
{
$this->db->select('*');
$this->db->from('inbook_special_phase_details');
$this->db->where('cat_id', $id);
$query = $this->db->get();
$n=$query->num_rows();
return $n;
}
}
My Controller....: Group12_Business
class Group12_Business extends Controller
{
function Group12_Business()
{
parent::Controller();
$this->load->helper(array('xml','url'));
$this->load->library('pagination');
$this->load->library('table');
}
function special_menu($id)
{
$a=$this->test_model->get_nrows('3',$this->uri->segment(3),$id);
$_SESSION['cat_id'] = $id;
$this->load->model('test_model');
$config['base_url'] = base_url().'index.php/Group12_Business/special_menu/';
$config['total_rows'] = $a;
$config['per_page'] = '3';
$config['full_tag_open'] = "<div id='pagination'>";
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data=array();
$data['results'] = $this->test_model->get_submenu($config['per_page'],$this->uri->segment(3),$id);
$this->load->view('view_special_menu_details',$data);
}
}
View file: 'view_special_menu_details.php
<table width="900" height="380" border="0">
<tr align="left">
<td height="10" colspan="3" align="center"><u><span class="style1">Special Menu Items</span></u></td>
</tr>
<?php
$i=0;
foreach($results->result_array() as $row)
{
$i++;
?>
<tr>
<td width="158"><DIV ID="right_special_menu_list" align="left"> <font color="#009900" face="tahoma" size="+1">Menu</font>
<DIV ID="left_sub_menu"> <a href="<?=base_url()?>index.php/Group12_Business/special_menu/1/" style="text-decoration:none;"><font color="#fd7700" face="tahoma" size="2">Today’s Top media</font></a> <br />
<a href="<?=base_url()?>index.php/Group12_Business/special_menu/2/" style="text-decoration:none;"><font color="#fd7700" face="tahoma" size="2">Service</font></a> <br />
<a href="<?=base_url()?>index.php/Group12_Business/special_menu/3/" style="text-decoration:none;"><font color="#fd7700" face="tahoma" size="2">Bussiness</font></a><br />
<br />
</DIV>
</DIV></td>
<td width="82" valign="top" align="center"> <a href="<?=base_url()?>assets/images/<? echo $row[" title="<? echo $row["
rel="sexylightbox[galleries]"> <img src="<?=base_url()?>assets/images/<? echo $row[" width="66" height="65" border="0"/></a> <br />
<u>
<?
echo $row["photo_caption"];?>
</u> </td>
<td width="598" valign="top" align="left"><p align="left"> <font color="#fd7700" face="tahoma" size="2"><b>
<?
echo $row["subject"];?>
</b></font> <br />
<br />
<? echo $row["details"];?> <br />
<br />
<br />
<hr />
</p></td>
<td width="44"></td>
</tr>
<tr></tr>
<? } ?>
<tr>
</table>
<div id="pagination" style="position:relative;margin-left:400px;margin-top:10px;">
<?php $this->table->generate($results); ?>
<table border="0">
<tr nowrap="nowrap">
<td> <img src="<?=base_url()?>assets/images/inbooo.gif"/></td>
<td nowrap="nowrap"><?php echo $this->pagination->create_links(); ?></td>
<td>
<img src="<?=base_url()?>assets/images/k.gif"/></td>
</tr>
</table>