public function index()
{
$config["base_url"] = base_url() . "index.php/admin_requirements/index";
$config["total_rows"] = $this->admin_requirements_full->record_count();
$config['per_page'] = 5;
$this->pagination->initialize($config);
$page = $this->uri->segment(3);
$data['results'] = $this->admin_requirements_full->display($config["per_page"], $page);
$data['links'] = $this->pagination->create_links();
$session_data = $this->session->userdata('logged_in');
$data['username'] = $session_data['username'];
$this->load->view('adminpanel/header',$data);
$this->load->view('adminpanel/menubar');
$this->load->view('adminpanel/footer');
}
function display($limit, $start)
{
$this->db->limit($limit, $start);
$query = $this->db->get('db_requirements');
return $query->result();
}
public function record_count()
{
return $this->db->count_all("db_requirements");
}
<?php
foreach($results as $data)
{
?>
<tr align="center">
<td height="29"><?php echo $data->id; ?></td>
<td><?php echo $data->cat_id; ?></td>
<td><?php echo $data->subcat_id; ?></td>
<td><?php echo $data->city; ?></td>
<td><?php echo $data->email_id; ?></td>
<td><?php echo $data->phone; ?></td>
<td><?php echo $data->publish; ?></td>
<td>Delete</td>
</tr>
<?php
}
?>
</table>
<p class="pages">Pages : <?php echo $links; ?></p>
[Sl.No] [category] [subcategory]
1 1 1
2 3 1
在上面的结果中,CATEGORY和SUBCATEGORY字段是数字。这些数字的实际值存储在另一个数据库表中。
我的问题是,我怎样才能检索上述数字的实际值。
我的CATEGORY和SUBCATEGORY数据库如下所示。
// db_bus_category
id, item
// db_bus_subcategory
id, cat_id, subcat_id, item
答案 0 :(得分:0)
如果需要从其他表中获取值,则需要使用SQL JOIN。粗略地看一下codeigniter文档的活动记录部分,显示了一个函数$ this-&gt; db-&gt; join();
https://ellislab.com/codeigniter/user-guide/database/active_record.html