hi guys, i have multiple recrods form for table “A” - just updating some records… no insertion…
on after update event i send the data as copy to table “B” - same structure, only one extra field for Autoincrement in the table “B”
this is to create a history update records…
my code is
$insert_table = 'TABLE_B';
$insert_fields = array(
'idintablea' => "'{id}'",
'field1' => "'{field1}'",
'field2' => "'{field2}'",
'field3' => "'{field3}'",
'field4' => "'{field4}'",
'field5' => "'{field5}'",
'field6' => "'{field6}'",
);
$insert_sql = 'INSERT INTO ' . $insert_table
. ' (' . implode(', ', array_keys($insert_fields)) . ')'
. ' VALUES (' . implode(', ', array_values($insert_fields)) . ')';
sc_exec_sql($insert_sql);
i want to to add a new field in table B and call it {fieldx} — and fill that field ONLY if {field1} has value “1” AND {field6} has the value “1”
moreover, the value in fieldx should have unique number if field is filled, or null is field is not field…
why? as this form is used for update only, it will repeatedly update the records and sends a copy to table_b… this will keep a track of field1 when be “1” and i can count it as one record for statistics … even if the other fields are changed during many-updates for each… hope it makes sense and i could explain the “why”
do you think this is doable easily? as if and else? and how to make the fieldx add unique id each time field1=1 and field6=1… i saw something like calculated by database and calculated… but didn’t understand how it works