DissObey Posted March 19, 2009 Posted March 19, 2009 I'm working on a little something and have hit a brick wall. The script requires users to input a number, which gets $_POST back to the page, the part im waving trouble with is to print a set code for the amount sent by the $_POST E.g You submit the value 5 in the input field the result you would get back would be $result $result $result $result $result I know its possible to do it with if statements .... if $_POST['num] == 1 but surely there is a more efficient way. Quote
Cronus Posted March 19, 2009 Posted March 19, 2009 Re: A little help with $_POST I actually started coding something to explain but what you put is very vague, and I'm not entirely sure what you are asking exactly. Quote
DissObey Posted March 19, 2009 Author Posted March 19, 2009 Re: A little help with $_POST The users submits a number to the script, say the number 5. Then the script will print 5 dropdowns. If the user submits the number 100 it should print 100 dropdowns Quote
Dave Posted March 19, 2009 Posted March 19, 2009 Re: A little help with $_POST You would need to use for or something im to tired to do it atm i might consider helping in the morning :). Quote
Vali Posted March 19, 2009 Posted March 19, 2009 Re: A little help with $_POST To see what was posted: <?php print_r($_POST); ?> Say you post the field "num": <?php // Validate post for ($i = 0; $i < $_POST['num']; $i++) { echo 'bla '; } ?> Read up on for loops: http://us3.php.net/manual/en/control-structures.for.php Quote
DissObey Posted March 19, 2009 Author Posted March 19, 2009 Re: A little help with $_POST Aha! works a charm, thanks for everyones help. Quote
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.