php insert multiple rows in MYSQL database

后端 未结 2 731
死守一世寂寞
死守一世寂寞 2021-01-29 08:28

I have a HTML form that i populate from database with a "foreach" loop, so the fields in the name have the same name. The data that i want to post back into the databa

2条回答
  •  囚心锁ツ
    2021-01-29 08:43

    Am not sure what your HTML looks like but having the same name for all your inputs does not neccessarily mean they have become an array. you will need to define them as array in HTML using []. Below is an example

    HTML

    PHP

    if(isset($_POST['submit'])){
    
    foreach($_POST['array'] as $myarray) {
    
        echo $myarray.'
    '; }

    this should get you the unique values from each input and then you do what you want with it.

    Here is a link to several other solutions that could help: Post text box array in PHP

提交回复
热议问题