有没有办法避免第一个和第二个选项卡上的重复数据? PHP 代码点火器

Is there a way to avoid duplicate data on the 1st and 2nd tab? PHP Codeigniter

我正在创建类似程序的购物车,所以在我请求或发送预订请求后,数据将放在第二个选项卡上。我已经这样做了,但问题是我需要删除第一个选项卡上选择的数据。这是供视觉参考的图像:

So the output should be: on the 1st tab, EO1 should only be available, and the highlited red circles should be placed on tab 2.

然后是我的第二个标签

I have already tried using new Array and Array push and in Array it but still giving the problem which the 1st tab data is still showing, how can I hide or remove the data that has been chosen from the 1st tab? here is my code

查看

第一个选项卡

<?php $newArray = array(); ?>

 <?php foreach($dorms as $dorm): ?>
  
    <?php 
        $res = $dorm['code'];
        array_push($newArray, $res);
    ?>

  <a class="text-decoration-none" href="<?php echo base_url() ?>pages/view/<?php echo $dorm['id']; ?>">
    <div class="col-md-6 mt-4" style="margin-left: 6rem;padding-bottom: 1rem;">
      <div class="card top-shadow" style="width: 12rem; text-align:center;display:inline-block;">
        <div class="card-body">
          <img src="<?php echo base_url(); ?>assets/images/dorms/<?php echo $dorm['image'] ?>" style="border-radius: 15%;width:100px;height:100px;">
          <hr class="border-black">
          <h5 class="card-title color-black">Room Type: <b><?php echo $dorm['type']; ?></b></h5>
          <h5 class="card-title color-black">Room Cost: <br><b> P <?php echo $dorm['price']; ?>.00</b></h5>

          <?php if ($dorm['status'] == 0): ?>
              <h5 class="card-title color-black"> <b>  <span class="badge badge-success">Reserve Now</span>  </b></h5>
          <?php elseif ($dorm['status'] == 1): ?>
               <h5 class="card-title color-black"> <b>  <span class="badge badge-info">Pending Reservation</span>  </b></h5>
          <?php endif; ?>

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

<?php endforeach; ?>

第二个选项卡

<?php foreach($dormreserved as $dormres): ?>
 
  <?php
      $pos = $dormres['code'];  
  ?>

  <?php if(in_array($pos, $newArray)): ?>

    <a class="text-decoration-none" href="<?php echo base_url() ?>pages/view/<?php echo $dormres['id']; ?>">
      <div class="col-md-6 mt-4" style="margin-left: 6rem;padding-bottom: 1rem;">
        <div class="card top-shadow" style="width: 12rem; text-align:center;display:inline-block;">
          <div class="card-body">
            <img src="<?php echo base_url(); ?>assets/images/dorms/<?php echo $dormres['image'] ?>" style="border-radius: 15%;width:100px;height:100px;">
            <hr class="border-black">

            <h5 class="card-title color-black">Room Type: <b><?php echo $dormres['code']; ?></b></h5>
            <h5 class="card-title color-black">Room Type: <b><?php echo $dormres['type']; ?></b></h5>
            <h5 class="card-title color-black">Room Cost: <br><b> P <?php echo $dormres['price']; ?>.00</b></h5>

            
              <h5 class="card-title color-black"> <b>  <span class="badge badge-info">Pending Reservation</span>  </b></h5>

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

<?php endif; ?>
<?php endforeach; ?>

控制器

public function home()
{
    // Check login
    if(!$this->session->userdata('student_logged_in')){
        redirect('students/login');
    }

    $data['title'] = 'Home';
    
    $data['dorms'] = $this->dorm_model->get_dorms();
    $data['dormreserved'] = $this->dorm_model->get_reserves();

    $this->load->view('templates/header', $data);
    $this->load->view('students/pages/home', $data);
    $this->load->view('templates/footer');

}

型号

public function get_dorms(){
    $this->db->order_by('id', 'DESC');
    $query = $this->db->get('dorms');
    return $query->result_array();
}


public function get_reserves(){
    $this->db->join('reserves', 'reserves.dorm_id = dorms.id');
    $this->db->where('reserves.tenant_id', $this->session->userdata('student_user_id'));
    $query = $this->db->get('dorms');
    return $query->result_array();
}

请更新get_dorms函数

public function get_dorms(){
    $this->db->where('id NOT IN(select dorm_id from reserves)');
    $this->db->order_by('id', 'DESC');
    $query = $this->db->get('dorms');
    return $query->result_array();
 }