CodeIgniter表生成链接

时间:2013-03-07 19:56:06

标签: php codeigniter

一旦我开始工作,我将把SQL代码移动到模型中,我知道它应该存在。但是如果不能开始的话,那就不会有任何帮助。我可能会遗漏一些东西,但是我如何将SQL结果'id'作为超链接(例如超链接www.mainsite.com/hw/id/$id)

我已经转发了index.php。

当前控制器:

function index()
{
    $this->load->library('pagination');
    $this->load->library('table');
    $this->load->library('form_validation');
    $this->load->helper(array('html','url'));

    $config['base_url'] = '/index.php/hw/id';
    $config['total_rows'] = $this->db->get('HWC')->num_rows();
    $config['per_page'] = 20;
    $config['num_links'] = 1;
    $config['full_tag_open'] = '<div class="pagination pagination-centered"><ul>';
    $config['full_tag_close'] = '</ul></div>';
    $config['cur_tag_open'] = '<li class="active"><a href="#">';
    $config['cur_tag_close'] = '</a></li>';
    $config['num_tag_open'] = '<li>';
    $config['num_tag_close'] = '</li>';
    $config['first_tag_open'] = '<li>';
    $config['first_tag_close'] = '</li>';
    $config['last_tag_open'] = '<li>';
    $config['last_tag_close'] = '</li>';

    $this->pagination->initialize($config);

    $this->db->distinct();
    $this->db->order_by('Col');
    $this->db->select('*');
    $where = array('ModelName IS NOT NULL' => null);

    $data['records'] = $this->db->get_where('HWC', $where, $config['per_page'], $this->uri->segment(3));

    $result = $this->table->set_heading('HWC #', 'Col #', 'Model Name', 'Series', 'Color', 'Tampo', 'Base Color', 'Base Type', 'Window Color', 'Interior Color', 'Wheel Type', 'Toy #', 'Country', 'Notes', 'Series #', 'Year Produced');
    $data['main_content'] = 'hw_view';
    $this->load->view('includes/template', $data);
}

当前观点:

<?php
  echo $this->table->set_template(array('table_open' => '<table class="table table-condensed table-hover">'));
  echo validation_errors('<p class="error">');
  echo $this->table->generate($records);
  echo $this->pagination->create_links();
?>

0 个答案:

没有答案