title: Why is my array only returning the last row
body: <p>I have searched the site, but can not find the answer or how it would relate to how I have my query set up. Here is my file that processing my post data and passes to db. I have form that is wrapped around a table. The cells in the table are populated by an array. When I leave this page I want the values in the table cells written to a new table in the db. Each row in the table represents a separate row in the db.</p>
  
  <p>Here is my form where all my post data is coming from.</p>
  
  <pre><code>    &lt;form action="post_movement.php?class_id=&lt;?php echo $class_id; ?&gt;&amp;pagenum=&lt;?php echo $pagenum; ?&gt;" method="post"&gt;
       &lt;table border=1 width=800px&gt;
   &lt;tr&gt;
   &lt;th width=300px&gt;Client&lt;/th&gt;
   &lt;th width=50px&gt;Order&lt;/th&gt;
   &lt;th width=200px&gt;Movements&lt;/th&gt;
   &lt;th&gt;Sets/Reps/Seconds&lt;/th&gt;  
   &lt;th width=150px&gt;Rest&lt;/th&gt;
   &lt;th&gt;X Completed&lt;/th&gt;
   &lt;/tr&gt;
  
  &lt;?php
  
  // Get workout class and output in table format -------------------------------------------------
  
  if(empty($workout_class) === false)
  {   
  foreach($workout_class as $wc){
  if ($wc['pagenum'] !== $pagenum) continue 1;
  
      echo '&lt;tr&gt;
          &lt;td&gt;&lt;input type="hidden" name="first_name[]" value="'.($wc['first_name']).'"&gt;'. ($wc['first_name']).'
          &lt;span&gt;&lt;input type="hidden" name="nickname[]" value="'.($wc['nickname']).'"&gt;('. ($wc['nickname']).')&lt;/span&gt;
          &lt;span&gt;&lt;input type="hidden" name="last_name[]" value="'.($wc['last_name']).'"&gt;'. ($wc['last_name']).'&lt;/span&gt;
          &lt;/td&gt;
                &lt;td&gt;&lt;input type="hidden" name="order[]" value="'.($wc['order']).'"&gt;'. ($wc['order']). '&lt;/td&gt;
                &lt;td&gt;
                &lt;select name="movement[]" width=200&gt;
                &lt;option&gt;'. ($wc['mv_00']). '&lt;/option&gt;
                &lt;option&gt;'. ($wc['mv_01']). '&lt;/option&gt;
                &lt;option&gt;'. ($wc['mv_02']). '&lt;/option&gt;
                &lt;option&gt;'. ($wc['mv_03']). '&lt;/option&gt;
                &lt;option&gt;'. ($wc['mv_04']). '&lt;/option&gt;
          &lt;/select&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="hidden" name="rep_set_sec[]" value="'.($wc['rep_set_sec']).'"&gt;'. ($wc['rep_set_sec']). '&lt;/td&gt;
          &lt;td&gt;&lt;input type="hidden" name="rest[]" value="'.($wc['rest']).'"&gt;'. ($wc['rest']). '&lt;/td&gt;
          &lt;td&gt;00&lt;/td&gt;
          &lt;/tr&gt;';
    } // foreach($data_array
      //print_r($data_array);
  } // if(!empty
  
  ?&gt;
  
  &lt;! End Table ----------------------------------------------------------------------------------&gt;
  &lt;/table&gt;
  &lt;input type="submit" value="Complete Movement"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is my php that process the post data from the form and submits it to the query.        </p>
  
  <pre><code>    if (empty($_POST)=== false){
  $movement_data = array('user_id', 'class_id', 'class_name', 'first_name', 'last_name', 'nickname', 'order', 'movement', 'rep_set_sec', 'rest', 'date');
  foreach($movement_data as $key =&gt; $value){
       $movement_data = array(
          'user_id'   =&gt; $session_user_id,
          'class_id'  =&gt; $_GET['class_id'],
          'class_name'    =&gt; $class_name,
          'first_name'    =&gt; $_POST['first_name'],
          'last_name'     =&gt; $_POST['last_name'],
          'nickname'  =&gt; $_POST['nickname'],
          'order'     =&gt; $_POST['order'],
          'movement'  =&gt; $_POST['movement'],
          'rep_set_sec'   =&gt; $_POST['rep_set_sec'],
          'rest'      =&gt; $_POST['rest'],
          'date'      =&gt; $today
          );
      }
  
      completed_movement($movement_data);
      //header('Location: new_client.php');
      //exit ();
  
      }
  </code></pre>
  
  <p>Here is my query that inserts the POST data into db.</p>
  
  <pre><code>    function completed_movement($movement_data){
  array_walk($movement_data, 'array_sanitize');
  
  $fields = '`' . implode('`, `', array_keys($movement_data)) . '`';
  $data = '\'' . implode('\', \'', $movement_data) . '\'';
  
  
  $query = mysql_query ("INSERT INTO `completed_movements` ($fields) VALUES ($data)");
  
  }
  </code></pre>
  
  <p>HTML form page has two table rows of data and looks like this.</p>
  
  <pre><code>    Colby (Big Cheese) Dodson | 1A | Key Movement | Sets/Reps/Seconds | Rest|
      -------------------------------------------------------------------------
      Mike (Big Mac) Mckenzie   | 1A | Key Movement | Sets/Reps/Seconds | Rest|
  </code></pre>
  
  <p>A var_dump ($_POST) produces this. I can see that value in there just not sure if it looks like its supposed to.</p>
  
  <pre><code>    array(7) { 
             ["first_name"]=&gt; array(2) { 
                 [0]=&gt; string(5) "Colby" 
                 [1]=&gt; string(4) "Mike" } 
             ["nickname"]=&gt; array(2) { 
                 [0]=&gt; string(10) "Big Cheese" 
                 [1]=&gt; string(7) "Big Mac" } 
             ["last_name"]=&gt; array(2) { 
                 [0]=&gt; string(6) "Dodson" 
                 [1]=&gt; string(8) "McKenzie" } 
             ["order"]=&gt; array(2) { 
                 [0]=&gt; string(2) "1A" 
                 [1]=&gt; string(2) "1A" } 
             ["movement"]=&gt; array(2) { 
                 [0]=&gt; string(12) "Key Movement" 
                 [1]=&gt; string(12) "Key Movement" } 
             ["rep_set_sec"]=&gt; array(2) { 
                 [0]=&gt; string(17) "Sets/Reps/Seconds" 
                 [1]=&gt; string(17) "Sets/Reps/Seconds" } 
             ["rest"]=&gt; array(2) { 
                 [0]=&gt; string(4) "Rest" 
                 [1]=&gt; string(4) "Rest" } 
             }
  </code></pre>
  
  <p>Is this what its supposed to look like when it does the var_dump? </p>
  
  <p>I need each row of my array to look like this. The first three values are the user_id, class_id, &amp; class_name and are not part of my html form on the previous page. These vales are picked up on the parsing script page and passed along with each row of my results.</p>
  
  <pre><code>    $row = array(29, 48, Class 1, Colby, Big Cheese, Dodson, 1A, Key Movement, Sets/Reps/Secons, Rest)
  </code></pre>
  
  <p>I need a row like this for each entry from my form.</p>