title: Adding multiple fields separated by comma into database PHP
body: <p>Thank you in advance for any help given! I'm very new to PHP and would love some advice/help! i want many id fields separated by comma to be inputted into a database separately with the same resource id variable. </p>
  
  <p><a href="http://i.stack.imgur.com/HHyq8.png" rel="nofollow">Find a link to a picture here! Here, a user enters many ids for the name, and only one ID for the resource, I would like all ids to be entered into the database with the same resource id beside it</a></p>
  
  <pre><code>//so this is creating the array to split up the ids
  $array = explode(",", $id);
  //finding length of array
  $length = count($array);
  //now we want to loop through this array, and pass in each variable to the db
  for ($x = 0; $x &lt; $length; $x++) {
   $sqlinsert= "INSERT INTO ids_to_resources (id, resource_id) 
      VALUES ($id [$x], $resource_id)"
  
      $result = mysqli_query($dbcon,$sqlinsert);
  } 
  </code></pre>
  
  <p>I think it could be something like this code above but it doesnt seem to be working for me...
  In short i want a user to enter many ID fields and only one resource field, and for this to be inputed into the database separately. I hope this makes sense! 
  Thanks again for any help given! </p>