I've read you can do variable variable names by using $$a for example, which means that the name of the variable = $a. So for example if $a = one, then the name of the variable $$a should be $one.
My question is, does this work when using forms as well? Here is part of a form I'm using:
if ($cds > 1) {
while ($x <= $cds) {
print "CD $x:<br>";
print "<input name=\"$x\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\"><br><br>"; //variable name is CD number, variable value will be the number of tracks in that CD#
$x++;
}
This script is run the second time the user loads the page. The first time they load it, they state how many CDs the album has. The second time (where this script comes in) will print a variable number of text boxes, depending on how many CDs there are, so the user can enter the number of tracks on each CD - that means the name of the textbox has to be variable. The user then clicks Submit again to view the page for the 3rd time.
This is where the problem is. Does the variable of the textbox get passed on to the next part of the script as $x, or will it forget the name of the variable, and only remember that actual name of the variable that was assigned to it? The reason I ask this is because this bit of the script, on the 3rd reload of the page, does not work:
while ($a <= $$x) {
//here, $a is the current track. $$x is the total number of tracks on this CD
print "<tr>";
print "<td width=\"50%\"><div align=\"right\">Track $a:</div></td>";
print "<td><input name=\"cd$i_track$a\" type=\"text\" size=\"40\"></td>";
$a++;
}
Any help would be appreciated.
Cheers,