In an application, if the user inserts a value in a input
, the variable named $nro_entrada_registro
will take that value and in addition a current date will automatically be inserted in a field called fecha_registro
. But when updating the value entered in input
by another, the field fecha_registro
is also updated and I do not want that. I want the date to be the first time the data was entered in input
and can not be modified. If the value is updated, the date does not change. This query works well for me:
if ($nro_entrada_registro == '') {
$sql4 = "UPDATE tramites SET estado_tramite='$estado',
nro_entrada_registro='$nro_entrada_registro',
fecha_registro=now() WHERE id_tramite='$id_tramite'";
$res = mysqli_query($con, $sql4);
} else {
$sql4 = "UPDATE tramites SET estado_tramite='$estado',
nro_entrada_registro='$nro_entrada_registro' WHERE
id_tramite='$id_tramite'";
$res = mysqli_query($con, $sql4);
}
I would like to know if there is a way to abbreviate this code so that only one question remains? Perform a kind of if
like the one I did, but within a query. I do not know if it's possible.