Php 如何显示数据以仅获取相同的列数据?

Php 如何显示数据以仅获取相同的列数据?,php,mysql,codeigniter,bootstrap-4,Php,Mysql,Codeigniter,Bootstrap 4,我对模式有一些问题。当我单击“详细订单”按钮时,未显示详细产品表。我的代码中的错误在哪里 如果我使用的是foreach$ordering,它只显示一个产品,而不显示另一个产品。当我使用foreach$detail\u buyer时,它应该显示客户购买的所有产品,但是,当我尝试时,它没有显示产品,它只显示模式引导 示例:当我单击ordering 00098和显示 所有产品的详细订单(1..2..3..) 我正在使用一个框架codeigniter和bootstrap模板 这是我的视图 <h1&

我对
模式
有一些问题。当我单击“详细订单”按钮时,未显示详细产品表。我的代码中的错误在哪里

如果我使用的是
foreach$ordering
,它只显示一个产品,而不显示另一个产品。当我使用
foreach$detail\u buyer
时,它应该显示客户购买的所有产品,但是,当我尝试时,它没有显示产品,它只显示
模式引导

示例:当我单击ordering 00098和显示 所有产品的详细订单(1..2..3..)

我正在使用一个框架
codeigniter
bootstrap
模板

这是我的视图

<h1>List Order</h1>
    <table class="table" width="900" border="0" cellspacing="1" cellpadding="1">
     <tr>
       <td width="250" align="center"><strong>Invoice</strong></td>
       <td width="200" align="center"><strong>Date Order</strong></td>
       <td width="160" align="center"><strong>Price</strong></td>
       <td width="250" align="center"><strong>Status</strong></td>
     </tr>
      <?php
        $no = $this->uri->segment(3) + 1;
        foreach($ordering as $row)
        {
      ?>
     <tr>
    <td align="center" valign="middle"><?php echo $row->invoice ?></td>
    <td align="center" valign="middle"> <?php echo poland_date($row->btn) ?></td>
    <td align="center" valign="middle">$<?php echo number_format($row->cart_total,2,',','.'); ?></td>
    <td align="center" valign="middle"><a href="#<?php echo $row->invoice; ?>" data-reveal-id="<?php echo 
    $row->invoice; ?>" class="btn btn-info btn-sm" data-toggle="modal">Detail</a>
 </td>

  </tr>
    <?php
            $no++;
        }
    ?>
</table>

<?php
        $no = $this->uri->segment(3) + 1;
        foreach($ordering as $row)
        {
?>
<div class="modal fade" id="<?php echo $row->invoice; ?>" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
    <<h3 class="modal-title">Detail Order <?php echo $row->invoice ?></h3>
    <button type="button" class="close" data-dismiss="modal">&times;</button>
  </div>

  <!-- Modal body -->
  <div class="modal-body">
    <table class="table table-striped">
      <thead>
      <tr>
        <th>Date</th>
        <th>Product</th>
      </tr>
      </thead>
      <?php
        $no = $this->uri->segment(3) + 1;
        foreach($list_product as $row)
        {
      ?>
      <tbody>
      <tr>
        <td> <?php echo $row->date;?></td>
        <td> <?php echo $row->product;?></td>
      </tr>
      </tbody>
      <?php
        $no++;
        }
      ?>
    </table>
    <br />
    <div align="center">
    <strong>Status :
    <?php 
        echo $row->status;  
    ?>
    </strong>
    </div>
    <br />
    <br />

  </div>

  <!-- Modal footer -->
  <div class="modal-footer">
    <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
  </div>
</div>
</div>
</div>
<?php
        $no++;
    }
?>
public function detail(){
        $this->check_logged_in();

        $id = $this->session->userdata('id');
        $email = $this->session->userdata('email');

        $data['ordering'] = $this->Buy_model->list_order_member($email);
        $data['list_product'] = $this->Buy_model->detail_buyer($hidden_id/*,$email*/);   
        $config['base_url'] = base_url().'Dashboard/detail/';
        $config['total_rows'] = $this->Buy_model->num_rows_detail($email);

        $this->load->view('frontend/detailpage',$data);
    }
这是我的买家\ U型

public function list_order_member($email){
        $this->load->database();
        $this->db->order_by('date','desc');
        $this->db->group_by('invoice');
        $this->db->distinct();
        $this->db->where('email',$email);
        $query = $this->db->get('order');
        return $query->result();
    }

public function detail_buyer($hidden_id/*,$email*/){
        $this->load->database();
        $this->db->order_by('qty','desc');
        $this->db->where('invoice',$hidden_id);
        $query = $this->db->get('order');
        return $query->result();
    }
[更新] 当我使用这个脚本时

<tbody>
            <?php
              $no = $this->uri->segment(3) + 1;
              $list_detail = $this->db->query("select * from order where invoice = '$rows->invoice'");
              foreach($list_detail->result_array() as $buys)
              {
            ?>
          <tr>
            <td> <?php echo $buys->date;?></td>
            <td> <?php echo $buys->product;?></td>
          </tr>
          <?php
            $no++;
            }
          ?>    
          </tbody>


如果结果是数组,则需要尝试以下代码:

<tbody>
<?php
$no = $this->uri->segment(3) + 1;
$list_detail = $this->db->query("select * from order where invoice = '$rows->invoice'");
foreach ($list_detail->result_array() as $buys) {
    ?>
        <tr>
            <td> <?php echo $buys['date']; ?></td>
            <td> <?php echo $buys['product']; ?></td>
        </tr>
    <?php
    $no++;
}
?>
</tbody>

这里使用了结果_array(),您是echo by->(箭头)运算符。您必须更改代码行

<?php
  $no = $this->uri->segment(3) + 1;
  $list_detail = $this->db->query("SELECT * FROM order WHERE invoice = '$rows->invoice'");
  foreach($list_detail->result() as $buys) //here is the changes made
  {
?>
    <tr>
        <td><?php echo $buys->date;?></td>
        <td><?php echo $buys->product;?></td>
    </tr>
<?php
    $no++;
}
?>    
</tbody>

您使用的是哪个版本的引导?bootstrap 4@DmitryCould you please var_dump($row->invoice);并在此处提供。请尝试var_dump($list_product)并在此处提供。在我的更新中,我没有使用$list_product。哦,是的,我忘记了调用数组的脚本。无论如何谢谢你