CodeIgniter Forums
Rookie $_POST Question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Rookie $_POST Question (/thread-10485.html)



Rookie $_POST Question - El Forum - 08-01-2008

[eluser]codelearn[/eluser]
Hey guys,

I have a form field that is filled dynamically by the database, like so:

Code:
<?php foreach($listing_q->result() as $sublist): ?>
  <input type="hidden" name="main_<?=$sublist->id; ?>" value="<?=$list->id; ?>" />
  <li>&lt;input type="checkbox" name="sub_&lt;?=$sublist-&gt;id; ?&gt;" id="&lt;?=$sublist->id; ?&gt;" /> &nbsp;&lt;?=$sublist->name; ?&gt;</li>
  &lt;? endforeach; ?&gt;
  &lt;!-- end for each subcategory --&gt;
</ul>
<br /><br />
&lt;? endforeach; ?&gt;

Somehow, in the controller method it posts to, I need to loop through all of the sub_&lt;?=$sublist->id; ?&gt;. I'm not sure how to loop through all $_POST variables (if thats even possible).

Any help would be much appreciated.


Rookie $_POST Question - El Forum - 08-01-2008

[eluser]Eric Cope[/eluser]
While it may not be intelligent to do this;
Code:
foreach($_POST as $var)
{
...
}
You should consider using the validation library though.