【发布时间】:2016-05-16 01:57:12
【问题描述】:
这是我的控制器
function search_keyword()
{
$cari = $this->input->GET('cari');
$data['dapat'] = $this->order_test_m->search($cari);
$this->load->view('admin/a',$data);
}
这是我的模特
function search($cari)
{
$this->db->from("uhd_user_order AS t1");
$this->db->join("uhd_user_product_order AS t2", "t1.user_order_id = t2.user_order_id");
$this->db->where('user_order_reference',$cari);
$query = $this->db->get('uhd_user_order');
return $query->result();
}
这是我的看法
<tr>
<th>No.</th>
<th>Customer Name</th>
<th>Product Code</th>
<th>Payment Type</th>
<th>Delivery Date</th>
<th>Total Price</th>
<th style="text-align: center;padding-right: 15px;">Action</th>
</tr>
<?php if($dapat !== NULL) { ?>
<?php foreach ($dapat as $row => $test) {
?>
<tr>
<td><?= $test->user_order_id?></td>
<td><?= $test->sender_name?></td>
<td><?= $test->user_product_order_id?></td>
<td><?= $test->payment_type ?></td>
<td><?= $test->time.$test->date ?></td>
<td><?= $test->delivery_price?></td>
</tr>
<?php }
}else{
echo "<td colspan='3'>no customer for the result!</td>";
}
?>
</table>
伙计们,我在这里需要帮助
我是codeigniter的新手。
我需要进行搜索,但搜索结果需要我的数据库中的 2 个表。 time、date 和 user_product_order_id 来自 uhd_user_product_order,user_order_id、sender_name、payment_type 和 user_order_reference(此搜索键)来自 uhd_user_order
在视图中我可以从我的表 uhd_user_order 中查看它,但我无法查看 time、date 和 user_product_order_id
你能帮我如何加入 2 表,以便我可以从搜索中看到最佳结果
【问题讨论】:
-
没关系,我明白了,我已经修好了
-
你能发表你的答案吗?
标签: php mysql database codeigniter join