0
The form is created through data obtained from the Mysql database. I would like to save all the data from it by clicking on the submit.
Problem:
I can only keep one line at a time, creating a boot in it
<tr>
and with the help of javascript Parent('tr');When saving the value of each of the generated text boxes dynamically, I cannot record the form completely, that is, what I want.
PHP Code of the Form
<?php
include('conetar.php');
$result = mysqli_query($conn,"SELECT * FROM `opcoes` WHERE `tipo` = 1 ;");
echo "<table class='table table-striped table-hover'id='datatables-example'>
<tr>
</tr>
<tr>
<td></td>
<td class='pure-table'><b>Antes da Instalação do Sistema Operativo</b></td>
<td class='pure-table'><b>Verificação</b></td>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tbody data-link='row' class='rowlink'>";
echo "<tr>";
echo "<td> <input type='hidden' name='IDOpcao' value=".$row['IDOpcao']."></td>";
echo "<td>" . $row['Opcao'] . "</td>";
echo "<td style='text-align:center;'> <input type='checkbox' name='Validacao'></td>";
echo "</tr>";
echo "</tbody>";
echo "<input type='hidden' name='IDOpcao' class='form-control' value='". $row['IDOpcao'] . "'>";
}
echo "</table>";
mysqli_close($conn);
?>
<br>
<?php
include('conetar.php');
$result = mysqli_query($conn,"SELECT * FROM `opcoes` WHERE `tipo` = 2 ;");
echo "<table class='table table-striped table-hover'id='datatables-example'>
<tr>
<td></td>
<td class='pure-table'><b>Instalação e Configuração (Base)</b></td>
<td class='pure-table'><b>Versão Antiga</b></td>
<td class='pure-table'><b>Versão Nova</b></td>
<td class='pure-table'><b>Verificação Prévia</b></td>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tbody data-link='row' class='rowlink'>";
echo "<tr>";
echo "<td> <input type='hidden' name='IDOpcao' value=".$row['IDOpcao']."></td>";
echo "<td>" . $row['Opcao'] . "</td>";
echo "<td> <input type='text' name='VersaoAntiga' id= 'VersaoAntiga-".$row['IDOpcao']."' class='form-control versao_antiga'></td>";
echo "<td> <input type='text' id='VersaoNova-".$row['IDOpcao']."' name='VersaoNova' class='form-control' disabled='true'></td>";
echo "<td style='text-align:center;'><input type='checkbox' name= 'VerificacaoPrevia'></td>";
echo "</tr>";
echo "</tbody>";
echo "<input type='hidden' name='IDOpcao' class='form-control' value='". $row['IDOpcao'] . "'>";
}
echo "</table>";
mysqli_close($conn);
?>
<!--Script para copiar para um ficheiro-->
<script>
$(document).ready(function(e){
$(".versao_antiga").on('input', function(e) {
var elemento = $(this);
var idElemento = elemento.attr("id").split('-')[1];
$("#VersaoNova-" + idElemento).prop('disabled', elemento.val().length == 0);
});
});
</script>
<br>
<!--Script para copiar para um ficheiro-->
<?php
include('conetar.php');
$result = mysqli_query($conn,"SELECT * FROM `opcoes` WHERE `tipo` = 3 ;");
echo "<table class='table table-striped table-hover'id='datatables-example'>
<tr>
<td></td>
<td class='pure-table'><b>Instalação e Configuração (Complementar)</b></td>
<td class='pure-table'><b>Versão Antiga</b></td>
<td class='pure-table'><b>Versão Nova</b></td>
<td class='pure-table'><b>Verificação Prévia</b></td>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tbody data-link='row' class='rowlink'>";
echo "<tr>";
echo "<td> <input type='hidden' name='IDOpcao' value=".$row['IDOpcao']."></td>";
echo "<td>" . $row['Opcao'] . "</td>";
echo "<td> <input type='text' name='VersaoAntiga' id= 'VersaoAntiga-".$row['IDOpcao']."' class='form-control versao_antiga'></td>";
echo "<td> <input type='text' id='VersaoNova-".$row['IDOpcao']."' name='VersaoNova' class='form-control' disabled='true'></td>";
echo "<td style='text-align:center;'><input type='checkbox' name= 'VerificacaoPrevia' ></td>";
echo "</tr>";
echo "</tbody>";
echo "<input type='hidden' name='IDOpcao' class='form-control' value='". $row['IDOpcao'] . "'>";
}
echo "</table>";
mysqli_close($conn);
?>
I’m creating a simple form, I don’t think it makes sense to use a MVC framwork for this case.I can record if it’s line by line using jquery with
parent('tr')
, but, I would like to store everything while submit.– djva
@djva Of course it makes sense to use PDO... and not MVC Framework. PDO is not a MVC Framework it only replaces MSQLI (which is depreciating). The MVC OO methodology etc helps you precisely with this, in solving problems... It is recommended that any system as long as a simple form follows the OO standards with Bean classes, DAO, etc... How long have you been working with PHP ?
– Anderson Souza