0
I have this code to make updat
and the countryside estad
o as completed and be the only field that can be edited:
<?php
$servername = "xxx.xxx.x.xx";
$username = "xxxxx";
$password = "xxxxxxx";
$dbname = "xxxxxxxx";
$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');
$result_cursos = "SELECT centrodb.RegistoManutencao.Id,
DataRegisto,
Pedido,
Outro,
Descricao,
Funcionario,
Imagem,
Tratamento,
Estado
FROM centrodb.RegistoManutencao LEFT OUTER JOIN centrodb.InfoLuvas
ON centrodb.InfoLuvas.Id = centrodb.RegistoManutencao.Colaborador
WHERE Estado IS NULL OR Estado <> 'Concluído';";
$resultado_cursos = mysqli_query($conn, $result_cursos);
$tabela1 .= '<div style="float: center" table align="center">';
$tabela1 .= '<table border="5">';
$tabela1 .= '<tr>';
$tabela1 .='<thead>';
$tabela1 .= '<tr>';
$tabela1 .= '<th>Nº Registo</th>';
$tabela1 .= '<th>Data</th>';
$tabela1 .= '<th>Pedido</th>';
$tabela1 .= '<th>Outro Local</th>';
$tabela1 .= '<th>Descrição</th>';
$tabela1 .= '<th>Colaborador</th>';
$tabela1 .= '<th>Estado</th>';
$tabela1 .= '</tr>';
$tabela1 .='</thead>';
$tabela1 .='<tbody>';
while($rows_cursos = mysqli_fetch_array($resultado_cursos)) {
$tabela1 .= '<tr>';
$tabela1 .= '<td>'.$rows_cursos['Id'].'</td>';
$tabela1 .= '<td>'.$rows_cursos['DataRegisto'].'</td>';
$tabela1 .= '<td>'.$rows_cursos['Pedido'].'</td>';
$tabela1 .= '<td>'.$rows_cursos['Outro'].'</td>';
$tabela1 .= '<td>'.$rows_cursos['Descricao'].'</td>';
$tabela1 .= '<td>'.$rows_cursos['Funcionario'].'</td>';
$tabela1 .= '<td> <input type="checkbox" name= "Id[]" value="'.$rows_cursos['Id'].'"></td>';;
$tabela1 .= '</tr>';
}
$tabela1 .= '</tr>';
$tabela1 .='</tbody>';
$tabela1 .= '</table>';
$tabela1 .= '</div>';
echo "<form method='POST' action=''>";
echo $tabela1;
echo "<input type='submit' name='registar' value='Registo'>";
echo "</form>";
echo "</br>";
echo "</br>";
?>
<?php
if(isset($_POST['registar']))
{
$servername = "xxx.xxx.x.xx";
$username = "xxxx";
$password = "xxxxxxx";
$dbname = "xxxxxx";
$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');
$id= $_POST['Id'];
$estado= $_POST['Estado'];
$conn->query("UPDATE RegistoManutencao SET Estado='$estado' WHERE Id=".$Id);
}
?>
But when does the update
table, fields are empty....
I need to see the HTML form to be sure the cause of the problem is really if the value is going to the method
POST
– RpgBoss
But this is independent of the form where the
insert
. Here I show the query and in the table of the query I want to do theupdate
of the status field with the value completed– user104114
I don’t understand what the problem is
não me faz o update na tabela da coluna checkbox com o nome estado:
– user60252
this verb is correct?
registar
...Registo
– user60252
and how to recover values via Post outside the form?
– user60252
So it is not possible to enter the value of the Status Column in the table where I register with the form? I thought it would recover the values when using the Post
– user104114
You have to put everything in the form (inputs, select, etcc, with name) to be able to submit and recover via POST
– user60252
You can put just one example?
– user104114
Table data can be edited?
– user60252