imarockstar Posted July 15, 2009 Share Posted July 15, 2009 Thanks for the help with the last post ... I know understand how that works !!!! This is my second question about arrays ... So I have a form that groups 3 input boxes together and returns the POST data into an array ... as follows : <?php if ( $_POST['submit'] ) { foreach($_POST['group1'] as $key=>$value){ echo "$key: $value<br />"; } } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" ?> <!-- group 1 --> field 1 : <input name="group1[text1]" size="20" > <br> field 2 : <input name="group1[text2]" size="20" > <br> field 3 : <input name="group1[text3]" size="20" > <br><br> <input type="submit" name="submit" value="test"> </form> the above works great !!!! What i need to do is ad 2 more groups of questions ... so that I can have 3 arrays ... each with the values of the groups of questions .. but i am nore sure how to modify the FOR EACH statement to allow this to happen ... as follows : <?php if ( $_POST['submit'] ) { foreach($_POST['group1'] as $key=>$value){ echo "$key: $value<br />"; } } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" ?> <!-- group 1 --> field 1 : <input name="group1[text1]" size="20" > <br> field 2 : <input name="group1[text2]" size="20" > <br> field 3 : <input name="group1[text3]" size="20" > <br><br> <!-- group 2 --> field 4 : <input name="group2[text1]" size="20" > <br> field 5 : <input name="group2[text2]" size="20" > <br> field 6 : <input name="group2[text3]" size="20" > <br><br> <!-- group 3 --> field 7 : <input name="group3[text1]" size="20" > <br> field 8 : <input name="group3[text2]" size="20" > <br> field 9 : <input name="group3[text3]" size="20" > <br><br> <input type="submit" name="submit" value="test"> </form> Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 15, 2009 Share Posted July 15, 2009 hmmz try this? not sure what'll happen <?php if ( $_POST['submit'] ){ for($i=1;$i<4;$i++){ foreach($_POST["group$i"] as $key=>$val){ echo "$key: $val<br />"; }//end foreach }//end for }//end if ?> lemme know [/php Quote Link to comment Share on other sites More sharing options...
imarockstar Posted July 15, 2009 Author Share Posted July 15, 2009 it worked !!!! thanks man !!!! i have the 3rd question coming soon !!! haha Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.