How can I get the values of multiple inputs by numbered ids and insert them into MySQL : <p>I tried to create a multi insert form where you can insert as many tiles and related languages as you want by filling in a number. The display of the Titles and language works fine, but I'm not able to get the different values and insert them into db. My aim is it that every Title with its Lang gets a unique ID in the db.</p>

<pre><code>&lt;form method="POST" action="" enctype="multipart/form-data"&gt;
 &lt;table&gt;
     &lt;tr&gt;
         &lt;th&gt;Title&lt;/th&gt;
         &lt;th&gt;Language&lt;/th&gt;
     &lt;/tr&gt;
 &lt;/table&gt;
 &lt;input id="count" type="number" placeholder="Number of Titles"&gt;
 &lt;input type="button" id="plus" value="+"&gt;
 &lt;input type="submit" id="save" name="save" value="Save"&gt;
 &lt;script type="text/javascript"&gt;
       $('#plus').on('click', function(){
            var queryString = "";
            var count = $('#count').val();
            var i;
            for(i = 1; i &lt;= count; i++){
                 $('table').append('&lt;tr&gt;&lt;td&gt;&lt;input name="title" type="text" placeholder="Title" id="Title_'+i+'" autocomplete="off" class="title"&gt;&lt;/td&gt;&lt;td&gt;&lt;select name="lang" id="Lang_'+i+'"&gt;&lt;option value="0"&gt;Romaji&lt;/option&gt;&lt;option value="ja"&gt;Japanese&lt;/option&gt;&lt;option value="en"&gt;English&lt;/option&gt;&lt;option value="de"&gt;German&lt;/option&gt;&lt;option value="ru"&gt;Russian&lt;/option&gt;&lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;');
            }
       });
       $('#save').on('click', function(){
        var Title = $('#Title_'+i).val();
        console.log(Title);
        queryString ='title='+Title+'&amp;lang='+Lang;

        jQuery.ajax({
            url: "action/insert.php",
            data: queryString,
            type: "POST",
            success:function(data){
                 location.reload();
            },
        });
       });  
     &lt;/script&gt;
&lt;/form&gt;
</code></pre>

<p>I also tried to get the value of the inputs via Jquery and send them with Jquery Ajax to the PHP file but I only get the output "undefined" when I tried to show the values in console</p>

<p>The insert.php</p>

<pre><code>&lt;?php
require "../config.php";
$title= $_POST['title'];
$lang= $_POST["lang"];

    $sql = "INSERT INTO MyGuests (title, lang) VALUES ('".$_POST['']."', '".$_POST['']."');";
    $sql .= "INSERT INTO MyGuests (title, lang) VALUES ('".$_POST['']."', '".$_POST['']."');";
    $sql .= "INSERT INTO MyGuests (title, lang) VALUES ('".$_POST['']."', '".$_POST['']."')";
    ...

    mysqli_multi_query($conn, $sql);
 ?&gt;
</code></pre>
