0
で二回登場する人物は、これが私のデータベースです:PHPのforeachのは、CodeIgniterの
表NAME:USER_ACCOUNT
Account_no Firstname Lastname Username Password
1 Larry Bird larryB larrylarry
2 Magic Johnson magic magiclakers
表NAME:tbl_items
Item_ID Item_Name Quantity Price Directory
1 gown 5 1000 gown.jpg
2 bridal 3 1500 bridal.png
テーブル名は:
をtbl_item_availedItem_availed_ID Item_ID Account_no Date_reserved Quantity
1 1 2 9/14/2016 2
2 2 1 9/14/2016 1
3 1 2 9/14/2016 1
so yepこれは私のテーブルであり、私はすでにそれら3に入社し、私の問題はこれです:
CLIENT予約VIEW:
CLIENT DETAILS
Magic details
Bird details
I:
CLIENT DETAILS
Magic details
Bird details
Magic details
はので、私はちょうどそれはこのようになりたいです既に詳細な領域を持っていますが、唯一のことはCLIENTの名前もLOOPSです、私はそれが唯一であることを望んでいます、私はそれをどうやって行いますか? HERESに私のコントローラのコード:
<div id="page-wrapper">
<table class="table table-hover">
<tr>
<th>CLIENT</th>
<th>DETAILS</th>
</tr>
<?php foreach($posts as $post) { ?>
<tr>
<td><?php echo $post->Firstname ?> <?php echo $post->Lastname; ?> </td>
<td><a href="<?php echo base_url(); ?>index.php/Pages_Controller/show_receipt/<?php echo $post->Username; ?>">details</a></td>
</tr>
<?php } ?>
</table>
クエリモデルの形で要求されるように:
public function getServicesAvailed($id){
$this->db->select('*');
$this->db->from("tbl_service_type");
$this->db->join("tbl_service_availed","tbl_service_availed.Service_ID = tbl_service_type.Service_ID");
$this->db->where('Account_ID',$id);
$this->db->where('active',1);
$query = $this->db->get();
return $query->result();
}