In a form I created a loop to show a list of files and next to each file a check box. To give each check biox a unique name, I wanted to add the number of the file to it. So first I did:
<input type="checkbox" name="<?php echo 'upload' . $a-1; ?>">
I made the calculation because I already increased $a before the HTML code came. The result was:
<input type="checkbox" name="-1">
The trick is to put the calculation between brackets, like this:
<input type="checkbox" name="<?php echo 'upload' . ($a-1;) ?>">
And this results in the 'name' being: "upload1", "upload2" etc.
My website: www.dejongfotografie.nl
Saturday, 21 April 2007
Subscribe to:
Posts (Atom)