title: Insert multiple rows into DB by only clicking one submit button
body: <p>I've got a little problem i hope you're able to help me fix.</p>
  
  <p>First of all my DB table that is involved look like this:</p>
  
  <pre><code>+---------------+--------------+------+-----+-------------------+----------------+
  | Field         | Type         | Null | Key | Default           | Extra          |
  +---------------+--------------+------+-----+-------------------+----------------+
  | id            | int(11)      | NO   | PRI | NULL              | auto_increment |
  | KlubID        | varchar(11)  | NO   |     | 0                 |                |
  | Medlemsnummer | varchar(11)  | NO   |     | 0                 |                |
  | KlubType      | varchar(128) | NO   |     |                   |                |
  | Handling      | varchar(128) | NO   |     |                   |                |
  | Tidspunkt     | timestamp    | NO   |     | CURRENT_TIMESTAMP |                |
  +---------------+--------------+------+-----+-------------------+----------------+
  </code></pre>
  
  <p>Say i got <strong>X</strong> entries where "Handling" equals <strong>Y</strong> in my table lets call the results <strong>P</strong> . Now I would like to take all <strong>P</strong> and insert a row foreach <strong>P</strong> where the value of "Handling" now will be equal to <strong>Q</strong>.</p>
  
  <p>The problem here is that I want to do the insert with one button (submit) not multiple forms.</p>
  
  <p>In advance thank you very much for your help. Feel free to ask for more info if this needs more clarity.</p>
  
  <p>/Nicki</p>
  
  <p>EDIT: For more clarity</p>
  
  <pre><code>public static function find_todays_children() {
      global $db;
      $sql = "SELECT * 
              FROM (
                  SELECT * 
                  FROM Handlinger 
                  AS a
                  WHERE date(Tidspunkt) = curdate() 
                  AND Tidspunkt = (
                      SELECT max(Tidspunkt) 
                      FROM Handlinger 
                      AS b
                      WHERE a.Medlemsnummer = b.Medlemsnummer
                      )
                  )
              AS c
              ORDER BY handling DESC, medlemsnummer";
      return static::find_by_sql($sql);
  }
  </code></pre>
  
  <p>This query above returns the following. </p>
  
  <pre><code>+------+--------+---------------+----------+----------+---------------------+
  | id   | KlubID | Medlemsnummer | KlubType | Handling | Tidspunkt           |
  +------+--------+---------------+----------+----------+---------------------+
  | 5786 | 0      | 1             | FK       | Kommet   | 2010-10-06 13:48:06 |
  | 5787 | 0      | 2             | FK       | Kommet   | 2010-10-06 13:48:10 |
  | 5789 | 0      | 4             | FK       | Kommet   | 2010-10-06 13:48:16 |
  | 5790 | 0      | 3             | FK       | G?et     | 2010-10-06 13:48:27 |
  +------+--------+---------------+----------+----------+---------------------+
  </code></pre>
  
  <p>I then want to be able to insert 3 rows where the field "Handling" is another value. 
  I can do this by HTML form with PHP but I can't figure out how to do it all by only clickin once...
  The important thing is that not to insert anything where the latest entry for a specific "Medlemsnummer" (user_id) is already equal to the value "Gået"</p>
  
  <p>My form looks like this:</p>
  
  <pre><code>...
      if(isset($action-&gt;Handling) != "Kommet") {
          $do_action = "Kommet";
      } else {
          $do_action = "Gået";
      }
  ...
  
  &lt;section&gt;
      &lt;form action="phineaslog_barn.php" method="post"&gt;
          &lt;label for="Status"&gt;Klub Navn: &lt;/label&gt;
          &lt;input type="text" name="Medlemsnummer" value="&lt;?php echo $child-&gt;Medlemsnummer; ?&gt;" /&gt;
          &lt;input type="text" name="Handling" value="&lt;?php echo $do_action; ?&gt;" /&gt;
          &lt;input type="submit" name="submit" value="&lt;?php echo $do_action; ?&gt;" /&gt;
      &lt;/form&gt;
  &lt;/section&gt;
  </code></pre>