Reply to Re: how to merge veriables?

Your name:

Reply:


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
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация