CodeIgniter Forums
Rookie $_POST Question - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Rookie $_POST Question (/thread-10485.html)

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

Hey guys,

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

<?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;
<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;
foreach($_POST as $var)
You should consider using the validation library though.