Reputation: 1011
Here is my view
<?php for($i=0;$i<count($acb['def']);$i++) { ?>
<input type="text" name="xyz" value="<?php echo $abc['def'][$i]?>" />?>
Here is my controller
$xxx=$this->input->post('xyz')
Now when i submit the form the last value only gets posted to controller
then i found that the name is same for all fields so it takes last value , so i changed the input name as
name ='xyz[$i]'
Now i need to post values , How to post values with this
Upvotes: 0
Views: 288
Reputation: 41
You use to below code...
<?php for($i=0;$i<count($acb['def']);$i++) { ?>
<input type="text" name="xyz[]" value="<?php echo $abc['def'][$i]?>" />
?>
Upvotes: 0
Reputation: 1134
You need to send name as array rename it to 'xyz[]' here
<input type="text" name="xyz[]" value="<?php echo $abc['def'][$i]?>" />?>
Upvotes: 1