简体   繁体   中英

Codeigniter - How to set name property from database

I'm using CodeIgniter and I have 2 questions:

  1. How do I call result from model to name property in any form inputs?
  2. How do I get the dynamic name property posted in Controller?

This is what I tried in my 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']

$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'] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM