How to handle un-assigned records

Posted by Mico on Stack Overflow See other posts from Stack Overflow or by Mico
Published on 2012-06-29T03:10:55Z Indexed on 2012/06/29 3:15 UTC
Read the original article Hit count: 158

Filed under:
|

I have this PHP page where the user can select and un-select items. The interface looks like this:

This is the interface on how we assign a location(right side) from available location (left side)

Now I'm using these code, when the user hit the save changes button:

foreach( $value as $al_id ){ //al_id is actually location id
    //check if a record exists
    //if location were assigned and leave it as is
    $assigned_count = $this->AssignedLoc->checkIfAssigned( $tab_user_id, $al_id ); 

    if( $assigned_count == 0 ){
        //else if not, insert this new record
        $this->insertAssigned( $tab_user_id, $company_id, $al_id );
    }

}

Now my question is, how do I delete the un assigned locations? For example in the screenshot above, there are 4 assigned locations, if I'm gonna remove (or unassign) "Mercury Morong" and "GP Hagonoy" from the assigned locations, only two must remain. What are the possible solutions using PHP?

Thanks for any help!

© Stack Overflow or respective owner

Related posts about php

Related posts about sql