这是我的控制器代码
public function edit_manpower($Manpower_id=null)
{
$session = session();
$db = ConfigDatabase::connect();
$builder = $db->table('Manpower');
$builder->select('Manpower.*');
$builder->where('Manpower_id', $Manpower_id);
$query = $builder->get();
$data['row'] = $query->getResultArray();
return view("admin/update_manpower_form",$data);
}
这是我的视图代码的错误产生:
<form action = "<?php echo site_url('Admin/updatemanpower/'.$row['Manpower_id']);?>" method=
"post" enctype="multipart/form-data">
<input type="hidden" name="_method" value="PUT"/>
<div class="form-group">
<div class=required-field><label for="Name">NAME:</label></div>
<input type="text" class="form-control" placeholder="Enter name" id="Name" value="<?php echo
$row['Name'];?>" name="Name" autocomplete="off">
</div>
<br>
<div class="form-group">
<div class=required-field><label for="Contact_no">CONTACT NUMBER:</label></div>
<input type="text" class="form-control" placeholder="Enter phone number" id="Contact_no"
value="<?php echo $row['Contact_no'];?>" name="Contact_no" autocomplete="off">
</div>
<br>
当我在View的顶部放置以下行时,将显示所需的数据:
<?php var_dump($row); ?>
显示的错误信息为:
Undefined array key "Manpower_id"
APPPATHViewsadminupdate_manpower_form.php at line 65
64 <br><br>
65 <form action = "<?php echo site_url('Admin/updatemanpower/'.$row['Manpower_id']);?>"
method= "post" enctype="multipart/form-data">
66 <input type="hidden" name="_method" value="PUT"/>
我找不到我做错了什么。请帮助。
您的$row可能是一个对象数组。#性病[]