dongxiaoguang9108 2015-07-27 07:52
浏览 11

如何在URL codeigniter中删除以前的方法?

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'] = '&laquo; First';
    $config['first_tag_open'] = '<li class="prev page">';
    $config['first_tag_close'] = '</li>';

    $config['last_link'] = 'Last &raquo;';
    $config['last_tag_open'] = '<li class="next page">';
    $config['last_tag_close'] = '</li>';

    $config['next_link'] = 'Next &rarr;';
    $config['next_tag_open'] = '<li class="next page">';
    $config['next_tag_close'] = '</li>';

    $config['prev_link'] = '&larr; 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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 连续两帧图像高速减法
    • ¥15 组策略中的计算机配置策略无法下发
    • ¥15 如何绘制动力学系统的相图
    • ¥15 对接wps接口实现获取元数据
    • ¥20 给自己本科IT专业毕业的妹m找个实习工作
    • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
    • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
    • ¥50 mac mini外接显示器 画质字体模糊
    • ¥15 TLS1.2协议通信解密
    • ¥40 图书信息管理系统程序编写