php - Multi select html inserting multi values into database -


i'm working on category section stories submitted website. have html select going on in html , have submitting database using codeigniter functions. submitting database, there seems small problem...the select grabbing last value selected. need have values selected entered database can pull them out @ later date.

this html using.

<select multiple class="multi" name="wgenre">                   <option value="action/adventure">action/adventure</option>                      <option value="angst">angst</option>                   <option value="crime">crime</option> </select> 

and have in model.

$this->title = $this->input->post('wtitle');     $this->genre = $this->input->post('wgenre');     $this->db->insert('story_tbl', $this); 

now, believe problem database. set field enum, won't work because it's either 1 or other selection , need have multiples. tried text field, , it's not grabbing everything. honest i'm @ loss , in need of help. :)

i ended solving without foreach loop.

first of all, writting html select tag wrong. select multiple values have add both [] @ end of class , muti tag...like this.

<select multiple="multiple" class="multi" name="wgenre[]"> 

and in php has json encoded placed in database correctly...like this...

$this->genre = json_encode($this->input->post('wgenre'));    

thank help! hope helps else in future! :)


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -