Announcement

Collapse
No announcement yet.

Multiple Select field insert to multiple records

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    $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
    Last edited by jsbinca; 02-10-2014, 01:06 AM.

    Comment

    Working...
    X