Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.