[英]Codeigniter - How to set name property from database
I'm using CodeIgniter and I have 2 questions: 我正在使用CodeIgniter,我有2个问题:
This is what I tried in my HTML: 这是我在HTML中尝试过的方法:
<input type="text" name="saa_<?php echo $row1['Tube_No']; ?>" value="<?= $row1['Pin_No']; ?>">
And this is what I tried in my controller: 这是我在控制器中尝试过的:
$data = array(
'SA_No' => $this->input->post('saa_.$row1'),
);
How do i get my form input name property get posted to controller. 我如何将表单输入名称属性发布到控制器。
First you need to get the value of $row1['Tube_No']
首先,您需要获取
$row1['Tube_No']
$valueDefinedWhenRenderingTheView = $row1['Tube_No'];
then you need to access it like this: 那么您需要像这样访问它:
$data = array(
'SA_No' => $this->input->post('saa_' . $valueDefinedWhenRenderingTheView)
);
because, when your defining the input name to be the concatenation of "saa_" and the value of $row1['Tube_No']
. 因为,当您定义输入名称为“ saa_”和
$row1['Tube_No']
值的串联时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.