I have problem with inserting data to MySQL from modal. My modal:
<a href=\"#\" class=\"badge badge-pill badge-success\">6 komentarzy</a> <a href=\"#\" class=\"badge badge-pill badge-danger\">brak komentarzy</a>
<a data-toggle=\"modal\" href=\"#add_desk_comm_{$desk_['desk_id']}\" data-target=\"#add_desk_comm_{$desk_['desk_id']}\" class=\"ediiit\">(dodaj)</a>
<div class=\"modal fade\" id=\"add_desk_comm_{$desk_['desk_id']}\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"edit_printer\" aria-hidden=\"true\">
<div class=\"modal-dialog\" role=\"document\">
<div class=\"modal-content\">
<div class=\"modal-header\">
<h5 class=\"modal-title\" id=\"exampleModalLabel\">Dodaj komentarz do zgłoszenia</h5>
<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">
<span aria-hidden=\"true\">×</span>
</button>
</div>
<form method=\"POST\" id=\"fr_{$desk_['desk_id']}\" action=\"".model_load('helpdeskmodel', 'addDeskComm', '')."\">
<div class=\"modal-body\">
<table class=\"table\">
<tbody>
<tr>
<td class=\"border-top-zero label\">Data zgłoszenia:</td>
<td colspan=\"2\" class=\"border-top-zero\">
<input type=\"number\" name=\"add_desk_comm_id\" id=\"inputPlace\" value=\"{$desk_['desk_id']}\" class=\"form-control\" autofocus>
</td>
</tr>
<tr>
<td class=\"border-top-zero label\">Data zgłoszenia:</td>
<td colspan=\"2\" class=\"border-top-zero\">
<input type=\"date\" name=\"add_desk_comm_date\" id=\"inputPlace\" class=\"form-control\" autofocus>
</td>
</tr>
<tr>
<td class=\"border-top-zero label\">Komentarz:</td>
<td colspan=\"2\" class=\"border-top-zero\">
<textarea name=\"add_desk_comm_opis\" rows=\"5\" id=\"inputDate\" class=\"form-control\" value=\"\" required=\"\" autofocus=\"\" style=\"margin-top: 0px; margin-bottom: 0px; height: 249px;\"></textarea>
</td>
</tr>
</tbody>
</table>
</div>
<div class=\"modal-footer\">
<button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">Anuluj</button>
<button type=\"submit_one\" name=\"add_desk_comm_sub_{$desk_['desk_id']}\" class=\"btn btn-warning\">Zapisz</button>
</div>
</form>
</div>
</div>
</div>
And form action
public function addDeskComm()
{
if(isset($this->__params['POST']['add_desk_comm_id']))
{
$add_desk_comm_id = $this->__params['POST']['add_desk_comm_id'];
$add_desk_comm_date = $this->__params['POST']['add_desk_comm_date'];
$add_desk_comm_opis = $this->__params['POST']['add_desk_comm_opis'];
$res = $this->__db->execute("INSERT INTO helpdesk_history (id, id_helpdesk, date, opis) SELECT NULL, '{$add_desk_comm_id}', '{$add_desk_comm_date}', '{$add_desk_comm_opis}' UNION ALL SELECT NULL, '{$add_desk_comm_id}', '{$add_desk_comm_date}', '{$add_desk_comm_opis}' LIMIT 1;");
}
return false;
}
Modal is in foreach and is repeated on the website (every row in the table has a modal). if you want to insert data into the mysql database, modal is executed as many times as there are rows in the table on the website. even modal id change does not help.
Any idea? I will add that I use only js bootstrap.