CI - 钻到单个帖子/线程

时间:2013-03-05 17:32:05

标签: php codeigniter

有人可以告诉我我做错了什么 - 我正在关注网络+视频,这会经历列出一系列帖子的过程,然后能够点击一个帖子,要显示细节。

我正在为我自己的解决方案/网络应用程序调整上述方法,但我不知道为什么我的数组是空白的。

我正在使用此行为下一个控制器创建链接/锚点

<a href="<?php echo base_url(); ?>Search/site/<?php echo $site->siteID; ?>"><?php echo $site->site_title; ?>

我突出了代码,我相信我会想念,

由于

控制器

        class Search extends CI_Controller {

    public function display($sort_by = 'site_title', $sort_order = 'asc', $offset = 0)
    {
    $limit = 20;
    $data['columns'] = array(
        'site_title' => 'Site Name',
        'site_uprn' => 'Unique Property Reference'
    );
    $this->load->model('search_model');
        $results = $this->search_model->search_sites($limit, $offset, $sort_by, $sort_order);

        $data['sites'] = $results['rows'];
        $data['num_results'] = $results['num_rows'];


        //pagination

        $this->load->library('pagination');
        $config = array ();
        $config['base_url'] = site_url("Search/display/$sort_by/$sort_order");
        $config['total_rows'] = $data['num_results'];
        $config['per_page'] = $limit;
        $config['uri_segment'] = 5;
        $this->pagination->initialize($config);
        $data['pagination'] = $this->pagination->create_links();

        $data['sort_by'] = $sort_by;
        $data['sort_order'] = $sort_order;



        $this->load->view('search', $data);
    }

    **function site($siteID){
    $this->load->model('search_model');
        $data['site_detail']=$this->search_model->site_detail($siteID);

        //$this->load->view('site', $data); 
        }   
}**

模型

 <?php
class Search_model extends CI_Model {

    function search_sites($limit, $offset, $sort_by, $sort_order){

        $sort_order = ($sort_order == 'desc') ? 'desc' : 'asc';
        $sort_columns = array('site_title', 'site_uprn');
        $sort_by = (in_array($sort_by, $sort_columns)) ? $sort_by : 'site_title';



     //site table
     $q = $this->db->select('siteID, site_title, site_uprn')
        ->from('sites')
        ->limit($limit, $offset)
        ->order_by($sort_by, $sort_order);

    $ret['rows'] = $q->get()->result();

     //count query

    $q = $this->db->select('COUNT(*) as count', FALSE)
        ->from('sites');

    $tmp = $q->get()->result();

    $ret['num_rows'] = $tmp[0]->count;

    return $ret;
    }

    **//sites details
    function site_detail($siteID){

    $this->db->select()->from('sites')->where('siteID', $siteID);
    $query = $this->db->get();
    return $query->first_row('array');
    }
}**

查看

   <div id="right">
         <h5>Site Details</h5>
         <ul>
         <li><?php $site_detail['siteID']?></li>
          <li><?php $site_detail['site_title']?></li>
         </div>

0 个答案:

没有答案