显示外键在模态中等于id的所有记录

时间:2016-08-10 05:22:56

标签: php database codeigniter loops records

我想将事务表中的所有记录显示到事务" records_id"等于记录" ID"但是然后只显示循环链接的当前行,即"点击这里"。对不起我的英语,但我希望你理解。请任何人!谢谢!

View:

<?php foreach ($results as $row): ?> 
<tr> 
<td> <input name="checkbox_<? echo $rows['ID']; ?>" type="checkbox"              id="checkbox[]" value="1"> </td>
<td><?php echo $row->ID; ?></td>
<td><?php echo $row->last_name; ?></td>
<td><?php echo $row->first_name; ?></td>
<td><?php echo $row->middle_name; ?></td>
<td>                                                       
<a href="#transaction" data-toggle="modal"
id="<? echo $rows['ID']; ?>"> Click Here </a>
</td>                                                       
</tr>                                               
<?php endforeach; ?>

/* Modal */
<!-- Transaction Pop-Up Window -->
<div class="modal fade" id="transaction">
<div class="modal-dialog">
    <div class="modal-content">

        <!-- Transaction Header --> 
        <div class="modal-header">
            <button class="close" data-dismiss="modal"> </button>
        </div>

        <!-- Transaction Body -->
        <div class="modal-body">
            <table class="table table-striped table-bordered col-xs-12">
                <thead>
                    <tr>
                        <th> Concern </th>
                        <th> Treatment </th>
                        <th> Status </th>                                                   
                    </tr>
                </thead>    

                <tbody>
                    <?php foreach ($results3 as $row): ?>
                    <tr>
                        <td> <?php echo $row ->concern; ?> </td>
                        <td> <?php echo $row ->treatment; ?> </td>
                        <td> <?php echo $row ->status; ?> </td>
                    </tr>
                    <?php endforeach; ?>                                                    
                </tbody>                                           
            </table>
        </div>

    </div>      
    </div>
    </div>




    model:

    function display3()
{
    $query = $this->db->query('SELECT * FROM transactions, records WHERE            transactions.records_id = records.ID');
    return $query->result();
}



   controller: 

    $this -> load -> model('model_admin');
        $data['results'] = $this -> model_admin -> display();

        $this -> load -> model('model_admin');
        $data['results2'] = $this -> model_admin -> display2(); 

        $this -> load -> model('model_admin');
        $data['results3'] = $this -> model_admin -> display3(); 
        $this -> model_admin -> display3($data);    


        $this -> load -> view('admin_home_view', $data);

0 个答案:

没有答案