尝试将具有相似列字段的多个数据数组上载到一个mysql表

I'm not sure how to ask this. I"m using php and mysql. I have multiple arrays of data that have similar information in them, the unique difference is that they all have a different categoryID that I am sending via an input hidden. I tested building and inserting arrays into mysql with a foreach loop, but only with one array of data, and it worked. However, I'm not sure how to do this with multiple tables where most of the columns have the same names and the categoryID is the differentiator. Below is an example of the data I'm trying to send and some of the column names. I'm trying to do all of this via one form.

>Table 1 to insert
>day1    day2    score  nameID  money   other   categoryID
>10      10      20     1       100     yes     1
>5       5       10     22      50      sure    1

>Table 2 to insert
>score  nameID  money   other   categoryID
>44     5      100              2
>55     89     44       no      2

>Table 3 to insert
>day1    day2    score  nameID  money   other   categoryID
>100     100     200    67      1000    no      3
>55      55      110    5       600     blah    3

Any clues as to what I should try to accomplish this would be greatly appreciated. Adding code samples of single array that works.

<table width='550' id='openResults' border='1' cellpadding='0'  cellspacing='0'>

    <tr>
          <td width="150"><input size="5" type="text" name="score[]"></td>
          <td width="150"><input size="5" type="text" name="name[]"></td>
          <td width="150"><input size="5" type="text" name="rsAmount[]"></td>
          <td width="100">&nbsp;</td></tr>

</table>



foreach ($_POST['name'] as $key =>$name) {
    $score=$_POST['score'][$key];
    $rsamount=$_POST['rsAmount'][$key];
    echo "<tr><td width='50'>$score</td><td width='50'>$name</td><td width='50'>$rsamount</td></tr>";
    $sql = "INSERT INTO testRows (score, name, rsAmount) VALUES ('$score', '$name', '$rsamount')";
    $result2 = mysql_query($sql) or die ("Error in query: $sql. " . mysql_error());
 }

Sorry all this is untested so you might need to fiddle with it, but hope it helps a little...

Try reformatting your inputs to include the id in the index like this:

      <td width="150"><input size="5" type="text" name="score[1][]"></td>
      <td width="150"><input size="5" type="text" name="name[1][]"></td>
      <td width="150"><input size="5" type="text" name="rsAmount[1][]"></td>

Then when you loop you can add a 2nd level to get the category ID from the [1] above:

foreach ($_POST['name'] as $categoyId => $data) {
  foreach ($data as $key =>$placeholder) {
    $name=$_POST['name'][$categoryId][$key];
    $score=$_POST['score'][$categoryId][$key];
    $rsamount=$_POST['rsAmount'][$categoryId][$key];
    echo "<tr><td width='50'>$score</td><td width='50'>$name</td><td width='50'>$rsamount</td></tr>";
    switch ($categoyId) {
       case 1:
          $sql = "INSERT INTO table_1 (score, name, rsAmount) VALUES ('$score', '$name', '$rsamount')";
          break;   
       case 2:
          $sql = "INSERT INTO table_2 (score, name, whatver) VALUES ('$score', '$name', '$rsamount')";
          break;   
       case 3:

          $sql = "INSERT INTO table_3 (score, name, somethingElse) VALUES ('$score', '$name', '$rsamount')";
          break;
       defaut: 
           $sql = null;
    }
    if ($sql) {
       $result2 = mysql_query($sql) or die ("Error in query: $sql. " . mysql_error());
    }
  } 
}