Creating a variable on the fly
Posted: Thu Oct 17, 2002 9:25 am
I need to loop through a sql update statement. The fields in the form have been given names with a number on the end depending on the ID in the table.
eg - foret1 on the first row, foret2 on the second.
To do the loop I am going to use a while loop and set $i to be 1 before the loop starts, increasing it each iteration of the loop.
But before I can even get that far I am having problems getting the value of the field from the form. Once I submit the form if I just output the value of $foret1 then I get the correct value. However, I need to generate the number to go on the end of this variable using $i. I have tried the following but it doesn't work.
echo($foret.$i);
I've also tried
echo($(foret.$i));
Infact I was getting so frustrated I was ending up trying ANYTHING
Any ideas?
eg - foret1 on the first row, foret2 on the second.
To do the loop I am going to use a while loop and set $i to be 1 before the loop starts, increasing it each iteration of the loop.
But before I can even get that far I am having problems getting the value of the field from the form. Once I submit the form if I just output the value of $foret1 then I get the correct value. However, I need to generate the number to go on the end of this variable using $i. I have tried the following but it doesn't work.
echo($foret.$i);
I've also tried
echo($(foret.$i));
Infact I was getting so frustrated I was ending up trying ANYTHING
Any ideas?