title: insert multiple same name input to database
body: <p>I know that this question has been already asked here, but I went through 20+ and couldn't get below code to work</p>
  
  <pre><code>&lt;form action="" method="post" &gt;
   &lt;td&gt;&lt;input name="field1[]" value="" &gt;&lt;/td&gt;
   &lt;td&gt;&lt;input name="field2[]" value="" &gt;&lt;/td&gt;
   &lt;td&gt;&lt;input name="field3[]" value="" &gt;&lt;/td&gt;
   &lt;td&gt;&lt;input name="field1[]" value=""&gt;&lt;/td&gt; 
   &lt;td&gt;&lt;input name="field2[]" value=""&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input name="field3[]" value=""&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input name="field1[]" value=""&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input name="field2[]" value=""&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input name="field3[]" value=""&gt;&lt;/td&gt;
   &lt;button type="submit" id="submit" name="submit" &gt; Go &lt;/button&gt;
  &lt;/form&gt;
  
  
  
  
  
  &lt;?php
  if(isset($_POST["submit"])){
  
      foreach($_POST['field1'] as $key =&gt; $value) {
  
          /* Attempt MySQL server connection. Assuming you are running MySQL
          server with default setting (user 'root' with no password) */
          $link = mysqli_connect("localhost", "dbuser", "dbpass", "dbname");
  
          // Check connection
          if($link === false){
              die("ERROR: Could not connect. " . mysqli_connect_error());
          }
  
          // Prepare an insert statement
          $sql = "INSERT INTO test (field1, field2, field3) VALUES (?, ?, ?)";
  
          if($stmt = mysqli_prepare($link, $sql)){
              // Bind variables to the prepared statement as parameters
              mysqli_stmt_bind_param($stmt, "sss", $field1, $field2, $field3);
  
              // Set parameters
              $field1 = $_REQUEST['field1'];
              $field2 = $_REQUEST['field2'];
              $field3 = $_REQUEST['field3'];
  
              // Attempt to execute the prepared statement
              if(mysqli_stmt_execute($stmt)){
                  echo "Records inserted successfully.";
              } else{
                  echo "ERROR: Could not execute query: $sql. " . mysqli_error($link);
              }
          } else{
              echo "ERROR: Could not prepare query: $sql. " . mysqli_error($link);
          }
  
          // Close statement
          mysqli_stmt_close($stmt);
  
          // Close connection
          mysqli_close($link);    
      }       
  }
  ?&gt;
  </code></pre>
  
  <p>My problem is clear - how to store this array to database. I am doing something wrong because my DB stores Array word instead of value. Any help would be massively appreciated</p>