variable as DB-fieldname

Use a variable as a database field name in ChronoForms.

Overview

CF does not natively support using a variable to specify a database field name in its actions.
Create a custom PHP block to build and execute an SQL query, using URL parameters as variables for the field name and value. Ensure the query is executed with the appropriate database command.

Answered
ChronoForms v6
Ed Eddi Bournell 01 May, 2019
When I call a form I pass some parameters via url. One of them is the fieldname of a database where I want to store a number.
Is it possible in CF6 to use a variable as fieldname?
Gr GreyHead 02 May, 2019
Hi Bournell,

The calling URL variables are added to the form data by ChronoForms - if you temporarily add a Debugger action you will see them there. Please see this FAQ for the corresponding short-codes.

Bob
he healyhatman 02 May, 2019
I don't think you can use a variable to replace the field name, but it would take you mere seconds to try.
Ed Eddi Bournell 03 May, 2019
I spent nights to find it out - no chance.
BUT
I want to use a php-block with this code:
$start =  $_GET["zeit"]; // These are the parameter I pass tu the Form via url
$position = $_GET["pos"];
$team = $_GET["team_nr"];

$db =\JFactory::getDbo();

$query = $db->getQuery(true);

$query -> update ('#__3s_starts') // this is my table where
-> set ("$position=$team") // I want to put the team-number
-> where ('Zeit='.$start); // at this specific time.

$db->setQuery($query);

echo $query->dump(); //for testing purpose

$db->close();
The Query-Dump :  
UPDATE svt38_3s_starts
SET Position1=63
WHERE Zeit=1567927800
But it does not work inside CF. Nothing will be written into the DB. ( It's possible to read from DB.) Pleeeze give me a hint....
he healyhatman 03 May, 2019
OK so I don't see there where you actually EXECUTE the query?
Ed Eddi Bournell 03 May, 2019
Answer
Yesss. it works. I was to blind to see......I just added:
$db->execute();
Thanks a lot. Now I can sleep better ;-)
This topic is locked and no more replies can be posted.