I build a catalog website. The catalog location is in http://localhost/bookstore/site/catalog
. Then if i click one of book the url change to http://localhost/bookstore/site/detail/100016
and it show the detail of book.
And now i click the pagination, the url change to http://localhost/bookstore/site/catalog/12
, its work fine. But if i click one of book, its doesnt show detail of book because the url change to http://localhost/bookstore/site/catalog/detail/100005
.
Can you see what different? yes, the url still save method catalog
so detail of book cant be shown. What should i do?
This my controller
public function catalog()
{
$config['full_tag_open'] = '<div class="pagination pagination-colory"><ul>';
$config['full_tag_close'] = '</ul></div>';
$config['first_link'] = '« First';
$config['first_tag_open'] = '<li class="prev page">';
$config['first_tag_close'] = '</li>';
$config['last_link'] = 'Last »';
$config['last_tag_open'] = '<li class="next page">';
$config['last_tag_close'] = '</li>';
$config['next_link'] = 'Next →';
$config['next_tag_open'] = '<li class="next page">';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = '← Previous';
$config['prev_tag_open'] = '<li class="prev page">';
$config['prev_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li class="page">';
$config['num_tag_close'] = '</li>';
$config['base_url'] = base_url('site/catalog');
$config['total_rows'] = $this->db->get('buku')->num_rows();
$config['per_page'] = 12;
//$config['uri_segment'] = 3;
$dari = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['databuku'] = $this->m_site->show_buku($config['per_page'],$dari);
$this->pagination->initialize($config);
$this->load->view('v_catalog_buku', $data);
}
Model
function show_buku($limit, $offset)
{
$this->db->order_by("id_buku", "desc");
$query = $this->db->get("buku", $limit, $offset);
return $query->result();
}
View
<table>
<div class="row">
<?php foreach($databuku as $row ):?>
<a href="<?php base_url(); ?>detail/<?php echo $row->id_buku; ?>"><div class="span3" style="height:450px;" >
<div class="icons-box">
<div class="row" style="height:100px;">
<div class="body"><h3><?php echo $row->judul; ?></h3></div>
</div>
<div class="row" style="height:200px;">
<img src="<?php echo base_url('uploads/'.$row->img);?>" height="120px" width="120px"/>
</div>
<div class="row">
<div><h3>Rp.<?php echo number_format($row->harga,2,",",".");?></h3></div>
</div>
</div>
</div></a>
<?php endforeach; ?>
</div>
</table>
<div class="box-content" align="center">
<?php echo $this->pagination->create_links(); ?>
</div>
<!-- end: Row -->
</div>