不同的modal获取相同查询sql的不同结果

时间:2016-10-31 08:33:11

标签: php codeigniter bootstrap-modal

我不知道代码有什么问题,但我得到了相同查询的不同结果。

我的选择查询(在控制器中):

$this->db->select('*');
$this->db->from('vendor_location');
$query = $this->db->get();
$data['location'] = $query->result_array();

我的部分视图(模态引导程序):

<div class="modal fade" id="add_driver_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">ADD DRIVER</h4>
              </div>
              <div class="modal-body" id='add'>
                <div class="row" id="add_driver_form">

                <?php var_dump($location);?>

                </div>
              </div>
              <div class="modal-footer">
                <button type="submit" class="btn btn-default" data-dismiss="modal">Close</button>
                <button id="add" type="button" class="btn btn-primary btn-md" onclick=add_driver()>Add</button>
              </div>
            </div>
            <div id="form_submit_result"></div>
          </div>
        </div>

<!-- Edit driver modal -->
        <div class="modal fade" id="edit_driver_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">EDIT DRIVER</h4>
              </div>
              <form method="post" action="<?php echo base_url(); ?>portal/edit_driver">
              <div class="modal-body" id='add'>
                <div class="row" id="edit_driver_form">

                    <?php var_dump($location);?>

                </div>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button id="save" type="submit" class="btn btn-primary btn-md">Save</button>
              </div>
            </div>
          </div>
        </div>

var_dump($location)中的add_driver_modal时,我得到了预期的结果(来自vendor_location表的所有记录)。但我只是获得edit_driver_modal中的最后一条记录(一行)。怎么会发生这种情况?

0 个答案:

没有答案