Jump to content

Recommended Posts

I want to be able to display the same thing multiple times, but the amount depends on what the user had input in on the previous page. How would I go about accomplishing this? I can use a $_GET['X'] to get the variable amount, but I don't know how to use it to where I can loop through something X amount of times.

Link to comment
https://forums.phpfreaks.com/topic/263878-loop-through-forms/
Share on other sites

Not really, what I want to do is loop through a form that I would have in html multiple times, so like when I click submit on one form it would basically grab that information and then refresh to the same form for them to input again. I guess it would just be a matter of what would i put in the submit button to call?

Link to comment
https://forums.phpfreaks.com/topic/263878-loop-through-forms/#findComment-1352263
Share on other sites

sorry lol, alright so I have one page where someone inputs a number, X, then hits submit. Once they hit submit it goes to a form page where they can enter information. What I want to do is take the number from the first page and display the form page that number of times. I will have a submit button where once they click that, I will then get their information, and then display the form again until they have gone through the form page X number of times.

Link to comment
https://forums.phpfreaks.com/topic/263878-loop-through-forms/#findComment-1352269
Share on other sites

You'd need to store the number of times to show the form in a session/hidden input. Then check if it's greater than 0. If it is, show a form and decrement it. When it hits 0, move on. Since you have many forms you need to keep storing the results in the session or in hidden inputs (unless you process it each time and add it to your DB or whatever you're doing with it)

Link to comment
https://forums.phpfreaks.com/topic/263878-loop-through-forms/#findComment-1352270
Share on other sites

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.