简体   繁体   中英

How to retrieve new record in view codeigniter

I have 2 record in my table, like this picture:

在此输入图像描述

then i insert 2 new record, but the new record doesn't appear in my view, i've checked in my table and the new record already saved.

在此输入图像描述

Here is my View :

<?php
      foreach($dts121 AS $row_dts121) {
           $kode_sample[] = $row_dts121->kode_sample;
           $jam_sampling[] = $row_dts121->jam_sampling;
      }
      $no=-1;
      foreach($dtdetail as $detail) { 
           $no++; ?>

           <tr>
              <td>
                  <?php echo $kode_sample[$no];?></td>
              <td>
                  <?php echo $jam_sampling[$no];?></td>
           </tr>
      <?php } ?>

The controller :

[.....] 
$dtdate            = addslashes($this->input->post('dtdate'));
$data['dtdate']    = addslashes($this->input->post('dtdate'));
$data['date']      = addslashes($this->input->post('dtdate'));
[.....]
$dts121 = $this->M_dts121->get_dts121($dtdate); 
$dtdetail = $this->M_formfrmfss121_01->get_detail_byid($id);

$data1 = array('dtdetail' => $dtdetail);
$data2 = array('dts121' => $dts121);

$this->load->view('form_input/V_form'.$frmcode.'_'.$frmvrs, array_merge($data, $data1, $data2));

And here is the model function:

var $tabel2 = 'tblfrmfrmfss121dtl';

function get_dts121($date) {
        $query = $this->db1->query("select a.detail_id, a.kode_sample, a.jam_sampling 
                                    FROM tblfrmfrmlqs083dtl a join tblfrmfrmlqs083hdr b ON a.headerid = b.headerid AND b.date_input = '$date'");
        return $query->result();
    }

function get_detail_byid($id) {
        $this->db1->from($this->tabel2);
        $this->db1->where('headerid', $id);
        $this->db1->where('stdtl','1');
        $this->db1->order_by("detail_id", "asc");
        $query = $this->db1->get();
        if ($query->num_rows() > 0) { //old 1
            return $query->result();
        }
    }

I run the query manually its working, but only in my view the new record doesn't appear. How do i get each new record to appear in my view ?

No need to use array_merge() just pass array to load view as:

$data["dts121"] =  $dts121;

$this->load->view('form_input/V_form'.$frmcode.'_'.$frmvrs, $data);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM