douquqiang1513 2019-01-18 00:58
浏览 27

更新数据codeigniter

The updated data still doesn't change. The possibility for an error is in the ubahTypeBarang function. I have tried to find a solution, but still can't update the changed data

This models

public function ubahTypeBarang ()
{
    $data = [
        "barang_kode"=> $this->input->post('barang_kode', true),
        "type_id"=> $this->input->post('type_id', true),
        "barang_nama"=> $this->input->post('barang_nama', true),
    ];

    $this->db->where('barang_id', $this->input->post('barang_id'));
    $this->db->update('barang', $data);

}

This view

<div class="form-row">
                            <div class="form-group col-md-2">
                                <label for="kode">Kode</label>
                                <input type="text" name="barang_kode" class="form-control text-uppercase" id="barang_kode" value="<?= $barang["barang_kode"]; ?>">
                                <small class="form-text text-danger"><?= form_error('kode') ?></small>
                            </div>
                            <div class="form-group col-md-4">
                                <label for="type">Type</label>
                                <select class="form-control" id="type_id" name="type_id">
                                    <?php foreach($type as $types) : ?>
                                        <?php if( $types->type_id == $barang['type_id']) : ?>
                                            <option value="<?php echo $types->type_id ?>" selected><?php echo $types->type_nama ?></option>
                                        <?php else : ?>
                                            <option value="<?php echo $types->type_id ?>"><?php echo $types->type_nama ?></option>
                                        <?php endif; ?>
                                    <?php endforeach; ?>
                                </select>
                                <small class="form-text text-danger"><?= form_error('type') ?></small>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="nama">Nama Barang</label>
                                <input type="text" name="barang_nama" class="form-control text-capitalize" id="barang_nama" value="<?= $barang["barang_nama"]; ?>">
                                <small class="form-text text-danger"><?= form_error('nama') ?></small>
                            </div>
                        </div>

        <button type="submit" name="tambah" class="btn btn-primary float-right">Tambah Data</button>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?