How to get the POST name of a field in a form that uses a counter [message #185931] |
Wed, 14 May 2014 23:22 |
Adrienne Boswell
Messages: 25 Registered: October 2010
Karma:
|
Junior Member |
|
|
I need to how to get the POST name of a field in a form that uses a
counter. The fields are named based on that loop. Below is a small
snippet of what I am doing:
<?php
$howmuch = array(20, 30, 5, 10, 15);
?>
<form method="post">
<?php
for($s=0;$s<count($howmuch);++$s)
{?>
<input type="text" name="howmuch<?php echo $s; ?>" value="<?php echo
$_POST[$howmuch ?]$s; ?>">
<?php } ?>
<input type="submit" value="Submit">
</form>
Here's where my problem is:
When the user hits submit, I would get something in the post array like:
howmuch0 : 20
howmuch1 : 30
howmuch2 : 5
howmuch3 : 10
howmuch4 : 15
On a regular form, value="<?php echo $_POST[$howmuch]; ?>" works just
fine, but since I'm naming the field in a loop, I need to have that, too.
Using $_POST[$howmuch ?]$s; is not valid.
I'm sure the answer to this is pretty simple, but I had a hard enough
time trying to figure out a subject for this post, let alone knowing how
to google for it.
TIA for your help. I appreciate it.
--
Adrienne Boswell
Arbpen Web Site Design Services - http://www.cavalcade-of-coding.info/
The Good Plate - Fresh Gourmet Recipes - http://the-good-plate.com/
Please respond to the group so others can share
|
|
|