tableselect checkboxes i want to change values of only checked elements on tableselect.
How can i do that please ?

this is my tableselect : 

$form['tab'] = array(
    '#type' =&gt; 'tableselect',
    '#header' =&gt; $header,
    '#options' =&gt; $rows,
    '#empty' =&gt; t('empty !'),

);
return $form;


i've also a submit button that makes changes (update database) on one column of the tableselect :

 $form['published'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('Publish'),
        '#states' =&gt; array(
            'invisible' =&gt; array(
            ':input[name="select_list"]' =&gt; array('value' =&gt; 'Published'),
            )
            ),
        '#submit'=&gt; array('publish_submit'),
    );


My function to make changes (to publish elements that aren't now) :

function publish_submit($form, &amp;$form_state){
$check = $form_state['values']['tab'];
//$check = array_filter($form_state['values']['tab']);

$sql = db_update('field_data_field_books');
$sql-&gt;fields(array('field_books_value'=&gt; 'Published')); 
$sql-&gt;condition('entity_id',$check); //update only books i checked on the tableselect
$query = $sql-&gt;execute();
   }


this is what dsm($check) returns (when i check one or more elements on the tableselect )



this is dsm($rows) (6 elements are ok): 





This is how i created the $rows :

$rows = array();



foreach ($result as $res){

    $rows [] = array(

            'book_title' =&gt; l($res-&gt; field_title_value, 'node/'.$res-&gt;entity_id),
            'book_state' =&gt; $res-&gt; field_state_value,
            'book_editor' =&gt; $res-&gt; field_editor_value,
            'book_categories' =&gt; $res-&gt; name,
            'edit_books'=&gt;l(t('Details'), 'node/'.$res-&gt;entity_id.'/edit'),
          );

}

$form['table'] = array(
    '#type' =&gt; 'tableselect',
    '#header' =&gt; $header,
    '#options' =&gt; $rows,
    '#multiple' =&gt; TRUE,
    '#empty' =&gt; t('nothing!'),

);
As beebee said on comments : 

$rows should be indexed like this :

foreach ($result as $res){

    $rows [$res -&gt; entity_id] = array(


and the condition of the publishing function :

function publishing_submit($form, &amp;$form_state){

    $check = array_filter($form_state['values']['table']);
    $sql = db_update('field_data_field_state');
    $sql-&gt;fields(array('field_state_value'=&gt; 'Published'));
    $sql-&gt;condition('entity_id', $check, 'IN');
    $sql-&gt;execute();
}


Thanx beebee