【发布时间】:2011-12-02 23:35:29
【问题描述】:
我试图在我的表格视图中显示两列,一列是文档的标题,下一列是文档的描述。我在选择的特定表中有一个名为“文件名”的列,其中存储了与标题和描述相关联的上传文档的名称。
我很好奇如何在将“文件名”列中包含的数据设置为标题的超链接值的同时设法只显示标题和描述? (基本上,我希望他们能够在点击文件名称后下载文件)
我相当确定我可以通过跳过表生成器并在视图中执行“foreach”以打印出结果集中的所有数据来手动完成此操作,但我愿意接受建议,因为这会导致草率的代码。下面是我的控制器的 sn-p。
<?php
class blah extends CI_Controller {
public function troubleshooting() {
$this->load->library('pagination');
$this->load->library('table');
$config['base_url'] = 'http://somewebsite.com/troubleshooting';
$config['total_rows'] = $this->db->get('document')->num_rows();
$config['per_page'] = 10;
$config['num_links'] = 10;
$this->pagination->initialize($config);
$data['records'] = $this->db->get('document', $config['per_page'],$this->uri->segment(3));
$this->db->select('doc_title, filename, description, category_id, product_id');
$this->db->where('category_id = 1');
$this->db->where('product_id = 1');
$this->db->order_by('doc_title', 'asc');
$this->load->view('blah/troubleshooting.php', $data);
}
}
【问题讨论】:
-
请在模型中查询
-
我知道这是一个最佳实践,但我只是在这个实例中构建了几个小的静态页面。是否有任何特定于我上面提到的目的的特定原因,您建议我在模型中放置查询?如果有,请您详细说明一下?
标签: php mysql codeigniter hyperlink html-table