0
I would like help to solve the following problem, in the editing part of a form I have fields that are created as "Rows" from the registration part, the registration is correct, however, in the edition I am not able to insert the changes in the respective lines (I believe it applies with something like a matrix).
Part of the save action
$regioes_nm = $_POST['nome_regiao'];
$regioes_cd = $_POST['code_regiao'];
for ($i = 0; $i < count($regioes_nm); $i++) {
$cd = $regioes_cd[$i];
// Grava Região
$nome_reg = $regioes_nm[$i];
$idRegiao = $conexao->consulta("UPDATE proprietario_regiao SET "
. " nome = '$nome_reg',"
. " data_cadastro = 'CURDATE()'"
. "WHERE $bd_ID = '$id'");
// Grava Gerente
$nome_ger = $_POST["nome".$cd."_ger"];
$telefone_ger = $_POST["telefone".$cd."_ger"];
$email_ger = $_POST["email".$cd."_ger"];
$senha_ger = $_POST["senha1".$cd."_ger"];
$ID_Inserido = $conexao->consulta("UPDATE proprietario_gerente SET "
." idRegiao = $idRegiao,"
." nome = '$nome_ger',"
." telefone = '$telefone_ger',"
." email = '$email_ger',"
." senha = '".base64_encode($senha_ger)."',"
." data_cadastro = 'CURDATE()'"
."WHERE $bd_ID = '$id'");
// Grava Técnico
$nome_tec = $_POST["nome".$cd."_tec"];
$telefone_tec = $_POST["telefone".$cd."_tec"];
$email_tec = $_POST["email".$cd."_tec"];
$senha_tec = $_POST["senha1".$cd."_tec"];
for ($j = 0; $j < count($nome_tec); $j++) {
$ID_Inserido = $conexao->consulta("UPDATE proprietario_tecnico SET "
." idRegiao = $idRegiao,"
." nome = '$nome_tec[$j]',"
." telefone = '$telefone_tec[$j]',"
." email = '$email_tec[$j]',"
." senha = '".base64_encode($senha_tec[$j])."',"
." data_cadastro = 'CURDATE()'"
."WHERE $bd_ID = '$id'");
}
}
}
I don’t understand how you’re editing the form. I understand that you are listing users row by row, and their data in editable input fields. but which link from Submit to update?
– Vinicius De Jesus
That’s exactly it, well the links are these:
<button type="submit" class="action-bullet" value="" name="Sair"><div class="action-save-quit"></div><span><?=TXT_BOTAO_EDITAR_E_SAIR?></span></button>
<button type="submit" class="action-bullet" value=""><div class="action-save"></div><span><?=TXT_BOTAO_EDITAR?></span></button>
– João Victor
But is the button in the print? Is there an error? .
– Vinicius De Jesus
No, it is not in the print, what I return is this: $connected->disconnect (); $_SESSION['msg'] = "ok|". TXT_ACAO_RETORNO_EDICAO; if ($_POST['opgrava']=='Quit') { header("Location: ../.../.home.php?area=".$sis_Nome_mP."_manage"); } Else { header("Location: ../../.home.php?area=".$sis_Nome_mP."_editar&id=$id"); } die();
– João Victor
With ajax I could use what?
– João Victor
Incidentally easier to use ajax is to create a form in each row and the Submit button would send the data to the update page.
– Vinicius De Jesus