Have MYSQL 'SET' element names be variables????

Tricky question here:

I’d really like to do this, and have spent many hours trying all sorts of solutions and nothing has worked. :frowning:

Normally variables are used for HTML, but I’d like to use a variable named with GET, as in:

choice-form-01-01.php?name=choice_01_name

to be used to name which variable updates a mysql database.

Sp i’d like to have the bolded text in the following line be from the ?name= in the above url:

[php]$SQL_1 = "UPDATE choice_group_01 SET

		`[b]choice_01_name[/b]` = '$data[[b]choice_01_name[/b]][/php]

i tried this (and a million other things) and it just doesn’t work:

[php]$name = $_GET[‘name’];

$SQL_1 = "UPDATE choice_group_01 SET

		`$name` = '$data[$name]'[/php]

ANY help would be MUCH appreciated. This has got to be possible, I’m just at my wit’s end as to how it can be done.

The reason I’m doing this is that there are 450 forms, with 450 sets of variables, and i’d like to have one form and name the UPDATE variables with a php $GET.

thanks!!!

Without knowing everything I’d say this is not the optimal way to setup the DB, but this is where you use arrays in the form probably. This confuses me as it should work depending upon what $data[‘choice_01_name’] is. You really haven’t given enough info.

[php]$name = $_GET[‘name’];
$SQL_1 = “UPDATE choice_group_01 SET $name = ‘$data[$name]’”;[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service