I have this code that I want to run and it's connected to my database and it uses to show the values on the table but every time I do an UPDATE query.
It updates the rest of the row with zeros except the one I've chosen. I want to keep my numbers on the row but only update the one that i chose but I can't figure it out how to!
I initialized the table with a row with Zeros (0s) and then with my web page application I want to change those values.
But if I have another value on the rest of the columns and I want to change this one, the rest of the values go to zero (the initial state of the table) (I don't know how to explain it better I think)
<?php
$showData = ("SELECT * FROM horario");
if ($new_user_activity['data'] == 'Seg' ) {
$segHora = $new_user_activity['horas'];
}
$sql = ("UPDATE horario SET seg=$segHora WHERE id=1");
if(!mysqli_query($conn,$sql)) {
echo("ERRO NA QUERY" );
}
else {
if(mysqli_query($conn,$sql)){
$sqlData = mysqli_query($conn,$showData);
while ($row = mysqli_fetch_array($sqlData,MYSQLI_ASSOC)){
echo($row['seg']);
}
}
}
?>
Its expected to keep my values from the other columns on the same row!