title: How to insert multiple select option in PHP MySQL when multiple='multiple' is enabled
body: <p>I have a FORM with method POST. In the form I have two select drop-down with multiple='multiple' enabled in both so that user can make multiple selections.</p>
  <p>Now I am using MySQL database to store data.</p>
  <p>I am using foreach loop to iterate all the selections made.</p>
  <p>Here is the image Select drop-down image</p>
  <p><a href="https://i.stack.imgur.com/zPSEg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zPSEg.png" alt="enter image description here" /></a></p>
  <p>My code</p>
  <pre><code>$cid = $row['cid'];
  $work_location = $_POST['work_location'];
  $interest = $_POST['interest'];
  
  foreach ($work_location as $value) {
      $work = $value;
  }
  
  foreach ($interest as $value) {
      $int = $value;
  }
  
  $insert_oth_data = &quot;INSERT INTO resume_spec_data
                              (cid, work_location, interest) 
                      VALUES('$cid', '$work', '$int')&quot;;
  mysqli_query($con, $insert_oth_data);
  
  echo var_export($work_location);
  echo var_export($interest);
  echo var_export($work);
  echo var_export($int);
  
  echo var_export( $insert_oth_data );
  </code></pre>
  <p>Here work_location and interest are the fields that will carry the multiple select values. I don't want to use implode function because it will make data extraction difficult as table grows. I want to store the values in saperate rows of database.</p>
  <p>The problem I am facing is that data is being inserted, but the problem is when I select multiple options only one data is being inserted not all.</p>
  <p>The result I get after inserting the data is:</p>
  <pre><code>array ( 0 =&gt; 'Delhi', 1 =&gt; 'NCR', )array ( 0 =&gt; 'Software development', 1 =&gt; 'Business analyst', 2 =&gt; 'Web development', )'NCR''Web development''INSERT INTO resume_spec_data(cid, work_location, interest) VALUES(\'1\', \'NCR\', \'Web development\')'
  </code></pre>
  <p>As you can compare from the image I have made multiple selections. But single data is being taken here</p>
  <p>For reference</p>
  <pre><code>$work_location contains array ( 0 =&gt; 'Delhi', 1 =&gt; 'NCR', )
  
  $interest contains 
  
  array ( 0 =&gt; 'Software development', 
          1 =&gt; 'Business analyst', 
          2 =&gt; 'Web development', 
  )
  </code></pre>
  <p>$work contains NCR</p>
  <p>$int contains Web development only</p>
  <p>$work and $int should also contains same as $work_location and $interest respectively.</p>
  <p>One thing that I found here is that I have applied Insert query outside the foreach loop maybe that is why only one value is being taken. Since I am using multiple select drop-down here with multiple='multiple' enabled, I don't know how to do this to achieve the result I want.</p>
  <p>Any help would be appreciated.</p>