2016-02-27 48 views
1

我有2個紀錄在我的表,像這樣的畫面:如何檢索鑑於笨新紀錄

enter image description here

然後我插入2個新的紀錄,但新的記錄不會出現在我的觀點,我檢查了我的表格,並且新記錄已保存。

enter image description here

這裏是我的查看

<?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 } ?> 

控制器

[.....] 
$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)); 

這裏是模式功能:

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(); 
     } 
    } 

我手動運行查詢它的工作,但只在我看來,新的記錄沒有出現。我如何讓每個新記錄出現在我的視圖中?

+0

什麼$日期查詢? – Gopalakrishnan

+0

按照這個'insert'然後'select'然後'show' –

+0

你插入了哪裏?什麼桌子? 'tblfrmfrmlqs083dtl'?或'tblfrmfrmlqs083hdr'? – roullie

回答

0

無需使用array_merge()只是傳遞數組加載視圖:

$data["dts121"] = $dts121; 

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