Buongiorno a tutti,
sto cercando di inizializzare una
tabella e lasciare i movimenti a zero ma non ci sono riuscito.


Codice PHP:
<?php    include("conexion.php");    $con=conectar(); ?>
<!DOCTYPE html><html lang="es"><head>    <meta charset="UTF-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <title>Inicializar en ceros la tabla gastos</title></head><body>    <?php            $categoria="Salario";            $mes1"0.00";            $mes2"0.00";            $mes3"0.00";            $mes4"0.00";            $mes5"0.00";            $mes6"0.00";            $mes7"0.00";            $mes8"0.00";            $mes9"0.00";            $mes10"0.00";            $mes11"0.00";            $mes12"0.00";
            
$pregunta "SELECT * FROM gastos";            $datos=mysqli_query($con$pregunta);


            if (
$datos){                while($row $datos->fetch_array()){                    $categoria $row['categoria'];                    $mes1 $row['01'];                    

                    
$sql="UPDATE gastos SET 01 = '$mes1' WHERE categoria='$categoria'";                    $resultado=mysqli_query($con,$sql);
                }                            }         
            if (
$resultado){                                   echo '<script language = javascript>                           alert("Tabla gastos inicializada correctamente.. presione enter para seguir.")                           self.location = "index.php"                            </script>';            }else{                            echo '<script language = javascript>                alert("ERROR---Tabla gastos No está inicializada .. presione enter para seguir.")                self.location = "index.php"                 </script>';   

            }            
    
?></body></html>
tabla1.png
Grazie e saluti