首页 > 解决方案 > 从两个不同的页面向数据库提交数据

问题描述

实际上我在这个 Codeigniter 编码中有点新,我试图从 2 个不同的页面提交一个值并将其放在 1 个表中,到目前为止我只能从 1 个页面提交一个值,是否可以将 2 个值提交到 1 个表?

我表中的列:

po_no, tgl_po, rev_po, vendor_po, pic_po, tofp_po, kurs_po, location_po, catatan_po

我的模型为我的数据库增加价值

public function addPurchaseOrder()
{
    $data = [
        "vendor_po" => $this->input->post('vendor',true),
        "tgl_po"=>$this->input->post('tanggal',true),
        "po_no" =>$this->input->post('po',true),
        "rev_po"=>$this->input->post('rev',true),
        "ref_po"=>$this->input->post('ref',true),
        "pic_po"=>$this->input->post('pic',true),
        "location_po"=>$this->input->post('location',true),
        "tofp_po"=>$this->input->post('top',true),
        "kurs_po"=>$this->input->post('kurs',true),
        "catatan_po"=>$this->input->post('catatan',true)
    ];
    $this->db->insert('purchase_order',$data);
}

我的表单结构基本上

<div class="form-group">
   <label for="catatan" class="control-label">Notes : </label>
      <div class="row mt-4">
         <div class="col-lg-12">
           <textarea name="catatan" id="catatan" cols="151" rows="15"></textarea>
         </div>
      </div>
</div>
<div class="row mt-3">
   <div class="col-lg-12">
     <a href="<?php base_url(); ?>tampil" class="btn btn-primary float-right" id="buton">Submit</a>
   </div>
</div>

这个页面基本上填满了除了 catatan_po 之外的所有表格列,不同的是按钮

<div class="col-lg-12">
   <button class="btn btn-primary float-right" type="submit" style="margin-bottom:50px;" id="buton">Save</button>
   <a class="btn btn-primary float-right" id="buton" href="<?php base_url(); ?>otorisasi">Back</a>
</div>

我做对了吗?

标签: mysqlsqlcodeigniter

解决方案


推荐阅读