|
Posted by Jerry Stuckle on 11/16/05 04:56
Dave wrote:
> This seems relatively simple, and I'm sure I've done it in the past, but
> I can't seem to come up with a solution.
>
> the following variables are sent via form using textbox inputs:
> $var_1 = 'var1';
> $var_2 = 'var2';
> $var_3 = 'var3';
>
> I want to use the variable values to create mySQL column names like so:
>
> $arr = array($var_ ????)
> foreach ($arr as &$value) {
> mysql_query ("ALTER TABLE table_name ADD $value varchar(100) NOT
> NULL");
> }
>
> The "????" indicates where I think I am getting stuck on how to capture
> the form data into an array. The variables are identical character
> length and numbered sequentially, so it is possible to do something like:
>
> $i = 1;
> while ($var_???? >= 1) {
> mysql_query ("ALTER TABLE table_name ADD $value varchar(100) NOT
> NULL");
> i++
> }
>
> Again, the "????" indicates where I think I'm getting stuck on how to
> cycle through the $var_x list.
>
> I know this probably rudimentary and I feel dumb for not being able to
> find the solution without coming here. I would really appreciate some
> direction.
>
> Thanks in advance
> -Dave
<input type="text" name="name[]" ... >
For each of the inputs. The brackets indicate all the values are to be
passed in the array named "name".
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|