tobeyt23 Posted October 26, 2007 Share Posted October 26, 2007 Need to check a group of form inputs and want to run them in a group instead of separate statements. This is what i have so far and no luck any suggestions. I just put the form fields as variables in these to test and this is a far as I got before I realized this may not be the best way. Any suggestions? Thanks <?php $exf1 = 1; $exf2 = 0; $exf3 = 1; $exf4 = 0; $exf5 = 0; $exf6 = 1; $ename1 = "Test"; $ename2 = ""; $ename3 = ""; $ename4 = ""; $ename5 = ""; $ename6 = ""; $etype1 = ""; $etype2 = ""; $etype3 = ""; $etype4 = ""; $etype5 = ""; $etype6 = ""; $edata1 = ""; $edata2 = ""; $edata3 = ""; $edata4 = ""; $edata5 = ""; $edata6 = ""; $extraFields = array($exf1, $exf2, $exf3, $exf4, $exf5, $exf6); $t = 1; foreach ($extraFields as $field) { if ($field == 1) { echo $ename[$t]; } $t++; } ?> Quote Link to comment Share on other sites More sharing options...
tobeyt23 Posted October 26, 2007 Author Share Posted October 26, 2007 This seems to work: <?php $exf1 = 1; $exf2 = 0; $exf3 = 1; $exf4 = 0; $exf5 = 0; $exf6 = 1; $ename1 = "Test 1"; $ename2 = "Test 2"; $ename3 = "Test 3"; $ename4 = "Test 4"; $ename5 = "Test 5"; $ename6 = "Test 6"; $etype1 = ""; $etype2 = ""; $etype3 = ""; $etype4 = ""; $etype5 = ""; $etype6 = ""; $edata1 = ""; $edata2 = ""; $edata3 = ""; $edata4 = ""; $edata5 = ""; $edata6 = ""; $extras = array($exf1.":".$ename1.":".$etype1.":".$edata1, $exf2.":".$ename2.":".$etype2.":".$edata2, $exf3.":".$ename3.":".$etype3.":".$edata3, $exf4.":".$ename4.":".$etype4.":".$edata4, $exf5.":".$ename5.":".$etype5.":".$edata5, $exf6.":".$ename6.":".$etype6.":".$edata6); $t = 1; foreach ($extras as $extra) { $setting = explode(':', $extra); if ($setting[0] == 1) { echo "Extra field ".$t." => ".$setting[1]."<br><br>\n"; } $t++; } ?> 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.