php - How to pass query string to controller -
i have page contains data database table. @ end of every row, there's update button allow users update specific row. tried make id readonly input, whenever click submit on row, value return $this->input->post() last row id. want return id @ click submit.
id name action
echo form_open('control/edit'); foreach($rs $db) { $row = array(form_input('id', $db['id']), $db['name'], form_submit('update', 'update')); $this->table->add_row($row); } echo $this->table->generate(); in control/edit controller,
$this->input->post('id') // returns id of last row. anyone know how do this? thank you.
sounds being passed call-by-reference rather setting value, or more simplisticly, last row's input name of "id" last occurance in html form, means 1 post'd.
ex:
<input name="id" value="a" /> <input name="id" value="b" /> <input name="id" value="c" /> <input name="id" value="d" /> if clicked submit, $this->input->post('id') = 'd';
try changing foreach like:
... form_input("id[{$db['id']}]", $db['id'] ... your $this->input->post('id') array, can key/value id clicked.
Comments
Post a Comment