Welcome Guest, Not a member yet? Register   Sign In
Get values from multiple select dropdown and store
#1

[eluser]Unknown[/eluser]
Hello,

I cannot handle this issue. I am trying to get values from multiple select and store them in the database. Could you please take a look at this and let me know what is wrong with this? Why my selection are not stored in array so i can insert them in the database.

My form:

Code:
<form name="choiceForm" method="POST" action="create">
<select  name="users[]" id="project-users">
             &lt;?php if($displayProjectStatus): ?&gt;
                &lt;?php foreach($displayProjectStatus as $status): ?&gt;
                <option class="drop-option" value="&lt;?= $status-&gt;ID_PROJECT_STATUS ?&gt;"> &lt;?= $status->PROJECT_STATUS_NAME  ?&gt;</option>
                &lt;?php endforeach ?&gt;
                &lt;?php else: ?&gt;
               <option class="drop-option">Cannot display users. </option>
                &lt;?php endif ?&gt;
           </select>      
            </fieldset>
            &lt;input type="submit" value="Submit" 100px;"/&gt;
        &lt;/form&gt;

My controller:

Code:
$dataUsers = array(
        'ID_USER' =>$this->input->post('users')
     );
    
     $this->db->insert_batch('arrayusers', 'ID_USER', $dataUsers);

I get a lot of errors when using the above code in controller regarding Argument #1 is not an array, The first argument should be an array etc. I tried some other codes but still the same or it stores 0 to db. Any idea how to handle this?




Theme © iAndrew 2016 - Forum software by © MyBB