Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8444641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:26:44+00:00 2026-06-10T09:26:44+00:00

I have searched the site, but can not find the answer or how it

  • 0

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.

Here is my form where all my post data is coming from.

    <form action="post_movement.php?class_id=<?php echo $class_id; ?>&pagenum=<?php echo $pagenum; ?>" method="post">
     <table border=1 width=800px>
 <tr>
 <th width=300px>Client</th>
 <th width=50px>Order</th>
 <th width=200px>Movements</th>
 <th>Sets/Reps/Seconds</th>  
 <th width=150px>Rest</th>
 <th>X Completed</th>
 </tr>

<?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 '<tr>
        <td><input type="hidden" name="first_name[]" value="'.($wc['first_name']).'">'. ($wc['first_name']).'
        <span><input type="hidden" name="nickname[]" value="'.($wc['nickname']).'">('. ($wc['nickname']).')</span>
        <span><input type="hidden" name="last_name[]" value="'.($wc['last_name']).'">'. ($wc['last_name']).'</span>
        </td>
              <td><input type="hidden" name="order[]" value="'.($wc['order']).'">'. ($wc['order']). '</td>
              <td>
              <select name="movement[]" width=200>
              <option>'. ($wc['mv_00']). '</option>
              <option>'. ($wc['mv_01']). '</option>
              <option>'. ($wc['mv_02']). '</option>
              <option>'. ($wc['mv_03']). '</option>
              <option>'. ($wc['mv_04']). '</option>
        </select></td>
        <td><input type="hidden" name="rep_set_sec[]" value="'.($wc['rep_set_sec']).'">'. ($wc['rep_set_sec']). '</td>
        <td><input type="hidden" name="rest[]" value="'.($wc['rest']).'">'. ($wc['rest']). '</td>
        <td>00</td>
        </tr>';
  } // foreach($data_array
    //print_r($data_array);
} // if(!empty

?>

<! End Table ---------------------------------------------------------------------------------->
</table>
<input type="submit" value="Complete Movement">

</form>

Here is my php that process the post data from the form and submits it to the query.

    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 => $value){
     $movement_data = array(
        'user_id'   => $session_user_id,
        'class_id'  => $_GET['class_id'],
        'class_name'    => $class_name,
        'first_name'    => $_POST['first_name'],
        'last_name'     => $_POST['last_name'],
        'nickname'  => $_POST['nickname'],
        'order'     => $_POST['order'],
        'movement'  => $_POST['movement'],
        'rep_set_sec'   => $_POST['rep_set_sec'],
        'rest'      => $_POST['rest'],
        'date'      => $today
        );
    }

    completed_movement($movement_data);
    //header('Location: new_client.php');
    //exit ();

    }

Here is my query that inserts the POST data into db.

    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)");

}

HTML form page has two table rows of data and looks like this.

    Colby (Big Cheese) Dodson | 1A | Key Movement | Sets/Reps/Seconds | Rest|
    -------------------------------------------------------------------------
    Mike (Big Mac) Mckenzie   | 1A | Key Movement | Sets/Reps/Seconds | Rest|

A var_dump ($_POST) produces this. I can see that value in there just not sure if it looks like its supposed to.

    array(7) { 
           ["first_name"]=> array(2) { 
               [0]=> string(5) "Colby" 
               [1]=> string(4) "Mike" } 
           ["nickname"]=> array(2) { 
               [0]=> string(10) "Big Cheese" 
               [1]=> string(7) "Big Mac" } 
           ["last_name"]=> array(2) { 
               [0]=> string(6) "Dodson" 
               [1]=> string(8) "McKenzie" } 
           ["order"]=> array(2) { 
               [0]=> string(2) "1A" 
               [1]=> string(2) "1A" } 
           ["movement"]=> array(2) { 
               [0]=> string(12) "Key Movement" 
               [1]=> string(12) "Key Movement" } 
           ["rep_set_sec"]=> array(2) { 
               [0]=> string(17) "Sets/Reps/Seconds" 
               [1]=> string(17) "Sets/Reps/Seconds" } 
           ["rest"]=> array(2) { 
               [0]=> string(4) "Rest" 
               [1]=> string(4) "Rest" } 
           }

Is this what its supposed to look like when it does the var_dump?

I need each row of my array to look like this. The first three values are the user_id, class_id, & 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.

    $row = array(29, 48, Class 1, Colby, Big Cheese, Dodson, 1A, Key Movement, Sets/Reps/Secons, Rest)

I need a row like this for each entry from my form.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:26:45+00:00Added an answer on June 10, 2026 at 9:26 am
    while($row = mysql_fetch_assoc($query));
    return $movement_data;
    
    print_r($movement_data);
    

    Your while loop goes through the whole array – there’s no code evaluated. When it finishes, it returns the last value, because that’s the only item in the variable. Your print_r is never going to be evaluated.

    Editted to add:

    foreach($movement_data as $key => $value);
    

    There’s also a trailing semicolon on your foreach statement. That will have the same result.

    Editted, again:

    Each form value is being passed as an array of values; so what you need to do is step through the arrays, and process them one by one. The code below should work, but I’ve not tested it.

    It’s looping on the $_POST["first_name"] array – for each of those values, it’s populating a temporary array, and passing that to your function. Some of those values are hard-wired, and some are coming from the equivalent array index – the first run through uses the index elements with a value of 0, and so on.

    $i = 0;
    while (isset($_POST["first_name"][$i])) {
        $movement_data = array(   
            'user_id'   => $session_user_id,   
            'class_id'  => $_GET['class_id'],   
            'class_name'    => $class_name,   
            'first_name'    => $_POST['first_name'][$i],   
            'last_name'     => $_POST['last_name'][$i],   
            'nickname'  => $_POST['nickname'][$i],   
            'order'     => $_POST['order'][$i],   
            'movement'  => $_POST['movement'][$i],   
            'rep_set_sec'   => $_POST['rep_set_sec'][$i],   
            'rest'      => $_POST['rest'][$i],   
            'date'      => $today   
            );   
    
        completed_movement($movement_data);
    
        $i++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sorry in advance I have searched the whole site but I can not find
I have searched this site and also googled but can't seem to find the
I think I searched thoroughly this site, but could not find answer to my
I have searched the web for 2 days and can not find the answer.
I have searched hi and low, but can't find an answer without a lot
I've searched the internet and can't find anything that works here. My footer is
Tried to find answer here but, no luck so, here goes; I would like
Preface: I am sure this is incredibly simple, but I have searched this site
I have searched for a general solution to this but only find answers to
I've searched through a bunch of pages, but can't find my problem, so I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.