Caffeinenyx Posted May 5, 2011 Share Posted May 5, 2011 I have forum options in a loop (ie value = Entry$i) I need to call GET_POST('Entry$i') and loop though the INSERT query $i times. If I put GET_POST in a loop, however, it does not work. It does not give an INSERT failed error so I assume it is not reading it. I have also tried putting if GET_POST('Entry1') outside the loop, but it does not like it. I dont know how many options are needed so I need it to generate the correct number. Then you can select $i options from duplicated option lists. (Ie) participant 1, 2 and 3 from a list of possibles. I have also use GET_POST, I use a function. Other sumbits (I not use what they are called, please set me know), work fine on this page. echo "Entry $Number: <select name = \"Entry$j\">"; for ($i = 1; $i<$EntNum+1; $i++) { etc etc then for ($i = 0; $i<$NumberOfEntrys; $i++) { if (isset($_POST['AddEntry']) && isset($_POST["Entry$i"])) //rest of this bit not executed -just insert Ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/235592-get_requestpost-in-a-loop-var-entryi/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 5, 2011 Share Posted May 5, 2011 You need to use an array for your form field(s) - http://us.php.net/manual/en/faq.html.php#faq.html.arrays Once you do this, you can use php's array functions, such as foreach, to iterate over the data. Any time you find yourself trying to make a series of numbered variables for a set of data, you should be using an array (arrays are for sets of related data.) Quote Link to comment https://forums.phpfreaks.com/topic/235592-get_requestpost-in-a-loop-var-entryi/#findComment-1210862 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.