Simplify MySQL INSERT query
Use indexing in HTML name attributes

&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;Dată / Interval orar&lt;/td&gt;
        &lt;td&gt;Denumire&lt;/td&gt;
        &lt;td&gt;Moderatori&lt;/td&gt;
        &lt;td&gt;Detalii&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;input name="DataInterval[0]" type="text" id="DataInterval1"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input name="Denumire[0]" type="text" id="Denumire1"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input name="Moderatori[0]" type="text" id="Moderatori1"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input name="Detalii[0]" type="text" id="Detalii1"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    ...
    &lt;tr&gt;
        &lt;td&gt;&lt;input name="DataInterval[n]" type="text" id="DataIntervaln"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input name="Denumire[n]" type="text" id="Denumiren"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input name="Moderatori[n]" type="text" id="Moderatorin"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;input name="Detalii[n]" type="text" id="Detaliin"&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;


Use the indexing on the server side

&lt;?php
$data = array();
foreach ($_POST["DataInterval"] as $index =&gt; $value) {
    $data[] = array(
        "DataInterval" =&gt; $_POST["DataInterval"][$index],
        "Denumire" =&gt; $_POST["Denumire"][$index],
        "Moderatori" =&gt; $_POST["Moderatori"][$index],
        "Detalii" =&gt; $_POST["Detalii"][$index],
    );
}


After this you only have to iterate throught the $data array and execute paramtrized INSERT SQL commands.


do not use old mysql lib
learn about PDO and prepared statements