|
Jeebus Kliest
|
|
3-of-a-Kind
Join Date: Jun 2005
Location: Escondido, CA
Posts: 105
|
|
I don't really know php, just plugging in what makes sense from my c/c++ history.
I have a form that is created and then populated based off specific values in a db.
I want the user to be able to edit those values, and submit them and then have those values updated in the db.
I can get the first part done...
but I can only get the second part done by posting every single variable as its own entity. I would much rather send across the values and run it through a for statement, but I don't believe the post syntax allows for that.
Lets say the posted form field name is
postedname1
postedname2
postedname3
and so on...
to get it to work I have to say...
$value[0] = $_POST['postedname1'];
$value[1] = $_POST['postedname2'];
$value[2] = $_POST['postedname3'];
etc...
I would rather run it something like this...
for($location=0;$location<16;$location++){
$value[$location] = $_POST['postedname$location'];
}
The formatting of that is obviously incorrect as it doesn't work, but how can I change the value of the post value to equal 'postedname1','postedname2' as the for statement goes up?
Anyone....Anyone...bueller...
|
|
|
Play for FREE and practice your game at...
Join the FTR Poker Forum to disable these banners and start posting!
|
|
thirteen
|
|
Straight
Join Date: Jul 2005
Posts: 235
|
|
Try this
for($location=0;$location<16;$location++){
$value[$location] = $_POST['postedname'.$location];
}
Concatenate the $location variable rather than sticking it within the quotes. This will work, i had to do something similar in a crunch on a recent project.
|
|
|
|
LeFou
|
|
4-of-a-Kind
Join Date: Jul 2004
Location: Dallas, TX
Posts: 2,361
|
|
just out of curiosity why are you not using postedname[] -- i.e. an array -- in the form?
|
|
|
|
TylerK
|
10-13-2005, 02:11 AM
Post subject: Re: php
|
#4 (permalink)
|
|
4-of-a-Kind
Join Date: Oct 2004
Location: PEANUT BUTTER JELLY TIME
Posts: 1,791
|
|
Quote:
|
Originally Posted by Jeebus Kliest
Lets say the posted form field name is
postedname1
postedname2
postedname3
|
Age <input type="text" name="postedname[]">
Sex<input type="text" name="postedname[]">
Location<input type="text" name="postedname[]">
Quote:
|
Originally Posted by Jeebus Kliest
for($location=0;$location<16;$location++){
$value[$location] = $_POST['postedname$location'];
}
|
for($i = 0; $i < count($_POST['postedname']); $i++) {
print $_POST['postedname'][$i];
}
|
|
TylerK: its just gambling if i want to worry about money i'll go to work lol
|
|
Jeebus Kliest
|
|
3-of-a-Kind
Join Date: Jun 2005
Location: Escondido, CA
Posts: 105
|
|
Since postedname is the name of the input box, I wasn't sure if it would allow it to be a variable in the html form itself.
Anyways thanks thirteen that was what I needed. I knew it was a stupid simple syntax error...would help to actually know the language but can get by. Now since that was basically the only thing holding me back I can finish the entire project.
|
|
|