kigogu Posted June 8, 2012 Share Posted June 8, 2012 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 More sharing options...
Jessica Posted June 8, 2012 Share Posted June 8, 2012 Are you asking how to do a for loop? <?php for($i=0; $i<$x; $i++){ //code } ?> Link to comment https://forums.phpfreaks.com/topic/263878-loop-through-forms/#findComment-1352258 Share on other sites More sharing options...
kigogu Posted June 8, 2012 Author Share Posted June 8, 2012 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 More sharing options...
Jessica Posted June 8, 2012 Share Posted June 8, 2012 That is completely different from your first post. And what you're saying now doesn't make any sense. Link to comment https://forums.phpfreaks.com/topic/263878-loop-through-forms/#findComment-1352265 Share on other sites More sharing options...
kigogu Posted June 8, 2012 Author Share Posted June 8, 2012 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 More sharing options...
Jessica Posted June 8, 2012 Share Posted June 8, 2012 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 More sharing options...
kigogu Posted June 8, 2012 Author Share Posted June 8, 2012 ....totally forgot about sessions =___= thanks xD sorry for being all complicated in my explanation Link to comment https://forums.phpfreaks.com/topic/263878-loop-through-forms/#findComment-1352272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.