title: mysql - insert many to many relationship
body: <p>I am trying to insert records in 2 different mysql tables. Here's the situation:</p>
  
  <p>Table 1: <code>is_main</code> that contains records of resorts with a primary key called <code>id</code>.</p>
  
  <p>Table 2: <code>is_features</code> that contains a list of features that a resort can have (i.e. beach, ski, spa etc...). Each feature has got a primary key called <code>id</code>.</p>
  
  <p>Table 3: <code>is_i2f</code> to connect each resort id with the feature id. This table has got 2 fields: <code>id_i</code> and <code>id_f</code>. Both fields are primary key.</p>
  
  <p>I have created a form to insert a new resort, but I'm stuck here. I need a proper mysql query to insert a new resort in the <code>is_main</code> table and insert in <code>is_i2f</code> one record for each feature it has, with the id of the resort id <code>id_i</code> and the id of the feature id <code>id_f</code>.</p>
  
  <pre><code>$features = ['beach','relax','city_break','theme_park','ski','spa','views','fine_dining','golf'];
  
  mysql_query("INSERT INTO is_main (inv_name, armchair, holiday, sipp, resort, price, rooms, inv_length, more_info)
  VALUES ('$name', '$armchair', '$holiday', '$sipp', '$resort', '$price', '$rooms', '$length', '$more_info')");
  
  $id = mysql_insert_id();
  
  foreach($features as $feature) {
      if(isset($_POST[$feature])) {
          $$feature = 1;
          mysql_query("INSERT INTO is_i2f (id_i, id_f) VALUES (" . $id . ", ?????????????? /missing part here????/ ); }
      else {
          $$feature = 0; }
  }
  </code></pre>
  
  <p>Thanks.
  Please, I'm going CrAzY!!!!!!!!!!!!!!</p>