Multiple Select field insert to multiple records

I have a form

Recorid
Task
Assignto

Assignto is a multiple Select FIELD, COMMA denominated (ie 3,56,8,9)

I want to insert into a table

Recordid, task and Assignto = 3
Recordid, task and Assignto =56
Recordid, task, Assignto = 8
Recordid, task, Assignto = 9

How can this be done

What to take an array and make invidious records

$inserts = array();
$assignos = explode(’,’,{Assigno}); //stick your values in an array

foreach($assignos as $assi_value) //walk throu
{
$inserts[] = β€˜(’.{Recordid}.’,’.{Task}.’,’.$assi_value.’)’; // build your records
}
if(count($inserts) > 0)
{
$values = implode(’,’,$inserts); // create your values for the insert
sc_exec_sql(β€œINSERT INTO table VALUES $values”); //insert your records in one shot
}

That should do it.

jsb

1 Like