我正在使用codeigniter-3开发web应用程序,我有一个更新或编辑表单,我正在将数据传递给视图文件,但数据没有在UI中绑定(输入字段为空),你能帮助我在哪里我错了…?
print_r(元数据)
Array ( [0] => stdClass Object ( [id] => 14 [book_id] => test_565 [book_name] => Pelerin [book_number] => 2323232 [address] => ssss [status] => 1 ) )
controller.php
$data = $res->stations;
//return print_r($data);
$this->load->view('edit-book',$data);
edit-book.php
<input type="text" name="product_title" class="form-control" value="<?php echo $data[stations]->book_name;?>" id="exampleInputName1" placeholder="">
在发送数据到视图文件之前分配键值,如下所示
$data['data'] = $res->stations;
视图文件
value="<?php echo $data[0]->book_name;?>"
更改控制器,
$data = array("stations"=>$res->stations);
$this->load->view('edit-book',$data);
in view
<input type="text" name="product_title" class="form-control" value="<?php echo $stations[0]->book_name;?>" id="exampleInputName1" placeholder="">