title: Multiple Variables Explode and Insert to MySQL
body: <p>I checked for a possible solution in the site and found no solution. I have a form which has two text fields for the user to enter Name and Mobile Number. By default the page shows only two fields. If the user wants he can add more. The problem is, I am unable to insert these multiple data into DB. Please see below. I do no have 10 reputations to post images. Hence I am giving an external link.</p>
  
  <p>1) The initial form
  <a href="http://postimg.org/image/qiojxjrcx/" rel="nofollow">http://postimg.org/image/qiojxjrcx/</a></p>
  
  <p>2) Clicking the plus symbol, user can add more fields
      <a href="http://postimg.org/image/zaetpokbx/" rel="nofollow">http://postimg.org/image/zaetpokbx/</a>
  <br>
  3) The fields added dynamically using Jquery have unique id's and a class. The script below is for getting the values of Staff Name and Mobile Number <br>
  a) Script for Getting Staff Name</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var addstaffname = new Array();
   $('input[class="addstaff"]').each(function() {
         addstaffname.push(this.value);
      }); </code></pre>
  </div>
  </div>
  
      <br>
  b) Script for Getting Mobile Number</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var addstaffmob = new Array();
   $('input[class="addstaffmob"]').each(function() {
         addstaffmob.push(this.value);
  }); </code></pre>
  </div>
  </div>
  
      <br>
  I am getting the values by using the class for Staff Name and Mobile. And through ajax I am posting these values in PHP.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$.ajax({
     type:"POST",
     url:"../../ajax.php",
     data:'addstaffname='+addstaffname+'&amp;addstaffmob='+addstaffmob,
     cache:false,
     success: function(data)
     {
      alert(data);
      
     }
     })</code></pre>
  </div>
  </div>
  
      <br>
  In ajax.php, I am storing these values into variables.<br></p>
  
  <pre><code>if(isset($_POST['addstaffname']))
  {
  $addstaffname = $_POST['addstaffname'];
  $addstaffmob = $_POST['addstaffmob'];
  $addstaffnameexploded = explode(',',$addstaffname);
  $addstaffmobexploded = explode(',',$addstaffmob);
  }
  </code></pre>
  
  <p><p>I am using explode as I have multiple values and all the values I get are CSV's from Jquery. I have a table called staff with three columns, staff_id,staff_name,staff_mobile and staff_id is PK and Auto Increment. My question is how do I insert staff name and mobile in the same row. Lets say we got staff name as A,B,C and mobile numbers as 100,200,300 from the form, I need to insert into MySQL DB with these values. So A will have mobile 100, B will have 200 and so on... If I had only one explode, I could easily use foreach loop and iterate. Very simple. I am going mad on how to insert data with this scenario. Any help will be highly appreciated.</p>