im trying to store the values in database, all the values are getting dtored in the database but the issue is with dropdown. when i try to upload the multiselect dropdown only the last selected value is getting stored, where as i want to store all the selected values in the database, can some one guide me how can i do that
//----controller-----
public function portfolio1()
{
$this->form_validation->set_rules('first_content', 'First content', 'required');
$this->form_validation->set_rules('second_content', 'Second content', 'required');
$this->form_validation->set_rules('type', 'Type', 'required');
if ($this->form_validation->run()==TRUE)
{
$config['upload_path'] = FCPATH.'uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
if ( $this->upload->do_upload('filename') )
{
//print_r($this->upload->data());die;
$data['first_content'] = $this->input->post('first_content');
$data['second_content'] = $this->input->post('second_content');
$data['type'] = $this->input->post('type');
$data['filename'] = $this->upload->data('file_name');
//Transfering data to Model
$this->Contact_model->portfolio1($data);
//Redirecting to success page
redirect(site_url('Home/portfolio1'));
}
else
{
$error = array('error' => $this->upload->display_errors());
print_r($error);die;
}
}
else
{
$this->load->view('portfolio1');
}
}
//----model----------
function portfolio1($data)
{
//saving records
$this->db->insert('portfolio1', $data);
}
//------view page-----
<?php echo form_open_multipart('Home/portfolio1'); ?>
<div style="padding-top:10%; padding-left:30%">
<div>
<textarea name="first_content" rows="4" cols="50"></textarea>
<span><?php echo form_error("first_content");?></span>
</div><br>
<div>
<textarea name="second_content" rows="4" cols="50"></textarea>
<span><?php echo form_error("second_content");?></span>
</div><br>
<div>
<select name="type" multiple>
<option value="*">All Works</option>
<option value=".bootstrap">Creative</option>
<option value=".html">Photography</option>
<option value=".wordpress">Web Development</option>
</select>
<span><?php echo form_error("type");?></span>
</div><br>
<div>
<input type="file" name="filename">
<span><?php echo form_error("filename");?></span>
</div><br>
<button type="submit" class="btn btn-default">Submit</button>
</div>
</form>