CodeIgniter Forums
retrieve multiple varibles from Input classs - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: retrieve multiple varibles from Input classs (/showthread.php?tid=22851)



retrieve multiple varibles from Input classs - El Forum - 09-22-2009

[eluser]Unknown[/eluser]
Is there a way to retrieve multiple variables from the Iput class?
Eg. I have random amount of checkboxes named ckeckbox_1, checkbox_2 .... checkbox_150 and so on
Is there a way to use the Input class in order to cycle through the post data and detect their status?

Thank you in advance for your time and effort


retrieve multiple varibles from Input classs - El Forum - 09-22-2009

[eluser]Phil Sturgeon[/eluser]
You can use a for loop for that, but I would prefer to do it this way.

Code:
<label>Something: </label>
&lt;?php echo form_input('checkbox[]');?&gt;
<label>Something Else: </label>
&lt;?php echo form_input('checkbox[]');?&gt;
<label>Something again: </label>
&lt;?php echo form_input('checkbox[]');?&gt;

Then in your controller:

Code:
foreach($this->input->post('checkbox') as $value)
{
   echo $value;
}