从模态向MySQL插入数据时遇到问题。 我的模态:
<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>
并采取行动
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;
}
模态位于foreach中,并在网站上重复(表中的每一行都有模态)。如果要将数据插入mysql数据库,则执行模态的次数与网站上表中的行数相同。即使模式ID更改也无济于事。
有什么主意吗?我要补充一点,我只使用js引导程序。