Lodius2000 Posted November 22, 2008 Share Posted November 22, 2008 can items in the $_POST array be array? if so would they be accessed by $_POST['item]['sub_item'] thanks Link to comment https://forums.phpfreaks.com/topic/133732-solved-the-_post-array-quickie/ Share on other sites More sharing options...
gevans Posted November 22, 2008 Share Posted November 22, 2008 Yes, that's exactly it!! Link to comment https://forums.phpfreaks.com/topic/133732-solved-the-_post-array-quickie/#findComment-695953 Share on other sites More sharing options...
Lodius2000 Posted November 22, 2008 Author Share Posted November 22, 2008 suite Link to comment https://forums.phpfreaks.com/topic/133732-solved-the-_post-array-quickie/#findComment-695954 Share on other sites More sharing options...
DarkWater Posted November 22, 2008 Share Posted November 22, 2008 Yes. This works especially well for checkboxes or just multiple items with the same name. The syntax is: <input name="test[]" type="text" /> <input name="test[]" type="text /> Submitting a form with those in it would set $_POST['test'] to an array with both pieces of data from the text fields. Link to comment https://forums.phpfreaks.com/topic/133732-solved-the-_post-array-quickie/#findComment-695955 Share on other sites More sharing options...
Lodius2000 Posted November 22, 2008 Author Share Posted November 22, 2008 so I want to split apart my post array so i can query the db post looks like this $_POST[1]['word'] $_POST[1]['replace'] $_POST[2]['word'] $_POST[2]['replace'] where the integer is a row number so to split it apart i use <?php foreach ($_POST[] as $word, $replace){ mysql_query("UPDATE badwords SET word = $word WHERE id={$_POST['id']}"); //repeat for replace } ?> is that right? thanks Link to comment https://forums.phpfreaks.com/topic/133732-solved-the-_post-array-quickie/#findComment-695967 Share on other sites More sharing options...
Lodius2000 Posted November 22, 2008 Author Share Posted November 22, 2008 solved... but I started a followup topic http://www.phpfreaks.com/forums/index.php/topic,226631.0.html Link to comment https://forums.phpfreaks.com/topic/133732-solved-the-_post-array-quickie/#findComment-695984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.