Referencing posted variables in loop
Posted: Wed May 14, 2003 3:27 pm
I am trying to take posted variables (lots) and loop through to put them in a sequence of mysql tables.
I am having trouble with how to reference the names easily.
Since they are named sequencially (sp), such as $name1, $name2, etc., I thought it might be easy to do
for ($i = 1;$i !=$max;$i++){
echo "$name.$i";
}
but, I obviously don't understand how to reference variable names using concatenation. Since there is no variable $name (without its number), then php doesn't understand.
Can I do this? I've tried various ways of putting things together ("$"."name".$i") and ("$name".$i) etc. but no luck.
Or, after reading about $_POST , I wonder if I can reference the posted vars by number? if posts are held in an array and I know the sequence, can I just loop through with $_POST[$i] ?
thanks once again for the pointers.
=a
I am having trouble with how to reference the names easily.
Since they are named sequencially (sp), such as $name1, $name2, etc., I thought it might be easy to do
for ($i = 1;$i !=$max;$i++){
echo "$name.$i";
}
but, I obviously don't understand how to reference variable names using concatenation. Since there is no variable $name (without its number), then php doesn't understand.
Can I do this? I've tried various ways of putting things together ("$"."name".$i") and ("$name".$i) etc. but no luck.
Or, after reading about $_POST , I wonder if I can reference the posted vars by number? if posts are held in an array and I know the sequence, can I just loop through with $_POST[$i] ?
thanks once again for the pointers.
=a