Yes - like that - you're almost there :-)
The variables $fieldname, $fieldtype and $fieldlength are lexically scoped (with my) and do not exist outside of the for loop. This is good - don't change that bit.
You'll need to build your query as you iterate through the for loop. Start the process before you enter the loop:
... my $query = "CREATE TABLE $table"; for ($f=1;$f<=$field;$f++) ...
Now, on each pass through the loop, add the appropriate syntax for each column after you've gathered the data:
my $fieldname=param('fieldname' .$f); my $fieldtype=param('fieldtype' .$f); my $fieldlength=param('fieldlength' .$f); $query .= "... }
When you exit the loop, $query should contain your complete CREATE TABLE statement.
-- Ken
In reply to Re^5: Using perl to Create a Table in a Database
by kcott
in thread Using perl to Create a Table in a Database
by mynameisG
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |