-2

iam using codeigniter

<select id="example-label" multiple="multiple">
    <option value="option-1">Option 1</option>
    <option value="option-2">Option 2</option>
    <option value="option-3">Option 3</option>
    <option value="option-4">Option 4</option>
    <option value="option-5">Option 5</option>
    <option value="option-6">Option 6</option>
</select>`

how to insert multi-select value

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
gokul
  • 41
  • 1
  • 6

1 Answers1

2

<select id="example-label" multiple="multiple" name='youroption[]'>
    <option value="option-1">Option 1</option>
    <option value="option-2">Option 2</option>
    <option value="option-3">Option 3</option>
    <option value="option-4">Option 4</option>
    <option value="option-5">Option 5</option>
    <option value="option-6">Option 6</option>
</select>

Add This in Your Contoller

<?php
function get_data()
{
$optiondata=$this->input->post('youroption');
var_dump($optiondata);
}
?>

or extract using loop

foreach($optiondata as $key=>$value)
{
echo $value;
}
Suraj Tripathi
  • 116
  • 1
  • 7
  • 1
    Please dont encourage these obvious ___do it all for me___ questions by actually providing an answer, even an answer as basic as this. Once the OP has tried this they will be back with _the next issue_ and _the next issue after that_ saying _No I want it to do ....._ or _Thats does not work because...._ We call it ___the rabbit hole___ and you are about to fall into one if you are not careful – RiggsFolly Sep 28 '16 at 12:43
  • i need to insert two or more value in database when selected is it only be inserted as an array can you give me the controller and model – gokul Sep 29 '16 at 04:16