I've been looking at dozens of topics, but I still can not find a solution.
I created a form that shows the data of the database table and when the data is changed I need to update the table row.
This is the code I have but does not do the update in the table:
<form action="" method="post">
<label>Insira a data:</label>
<input name="data" type="date" placeholder="Type Here">
<br>
<br>
<input type="submit" value="Enter">
</form>
<?php
if(isset($_POST['data']))
{
$servername = "xxx.xxx.x.xx";
$username = "xxxxx";
$password = "xxxxxxxxx";
$dbname = "xxxxxxxx";
$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');
$inicio = mysqli_real_escape_string($conn, $_POST['data']);
$sql = "SELECT 'regOratorio'.'DataEntrada',
'regOratorio'.'Utente',
'regOratorio'.'Estado',
'regOratorio'.'Observacao',
'InfoLuvas'.'Funcionario'
FROM 'centrodb'.'regOratorio' LEFT OUTER JOIN 'centrodb'.'InfoLuvas'
ON 'centrodb'.'InfoLuvas'.'Id' = 'centrodb'.'regOratorio'.'Colaborador' WHERE DataEntrada = '$inicio'";
$result=mysqli_query($conn, $sql);
if (!$result) {
echo 'There are no results for your search';
} else {
// result to output the table
echo '<form name="customer_details" action="" method="POST" onsubmit="return alguma_funcao()">';
}
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
echo "<fieldset>";
echo "<table cellspacing='10'>";
echo "<tr>";
echo "<td>";
echo "<label>Data</label>";
echo "<input type='date' id='DataEntrada' name='DataEntrada' value='".$row['DataEntrada']."'";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</fieldset>";
echo "<fieldset>";
echo "<table cellspacing='10'>";
echo "<tr>";
echo "<td>";
echo "<label>Utente</label>";
echo "<input id='' type='text' value='".$row['Utente']."'";
echo "<label>Estado</label>";
echo "<input type='radio' id='Estado' name='Estado' value='Presente' " . ( ($row['Estado']=='Presente') ? 'checked' : '' ) ."> Presente";
echo "<input type='radio' id='Estado' name='Estado' value='Ausente' " . ( ($row['Estado']=='Ausente') ? 'checked' : '' ) ."> Ausente";
echo "<label>Observacão</label>";
echo "<input type='text' id='Observacao' name='Observacao' value='".$row['Observacao']."'";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</fieldset>";
echo "<fieldset>";
echo "<table cellspacing='10'>";
echo "<tr>";
echo "<td>";
echo "<label>Colaborador</label>";
echo "<input type='text' id='Funcionario' name='Funcionario' value='".$row['Funcionario']."'";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</fieldset>";
echo "<input name='atualizar' type='submit' id='atualizar' value='Atualizar'>";
}
echo "</form>";
}// end submitted
?>
<?php
if(isset($_POST['atualizar']))
{
$data = $_POST['DataEntrada'];
$estado = $_POST['Estado'];
$observacao = $_POST['Observacao'];
$estadofinal = $_POST['EstadoFinal'];
echo $sql1 = "UPDATE regOratorio SET Estado = '$estado', Observacao = '$observacao', EstadoFinal = '$estadofinal' WHERE DataEntrada = '$data'";
if ($conn->query($sql1) === TRUE);
//Count total number of rows
$rowCount = $query->num_rows;
}
$conn->close();
?>
When I update it shows this data inside if(isset($_POST['atualizar']))