Jump to content

GET_REQUEST/POST in a loop var Entry$i


Caffeinenyx

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/235592-get_requestpost-in-a-loop-var-entryi/
Share on other sites

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.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.