how to get a value in the table and sum with which to enter in php

0

I am making a bank account system and in one of the operations the user has to perform deposit only that my doubt this I already did the update of the table that takes the value that the user and changes in the table more like sum with what it had in the table

ex

The user puts 100 $ more in the table has 50 his balance and to get 150 $

How can I do this?

what I've done

<?php include 'conecta.php';?>

	<html>
	<head>
	<meta http-equiv="content-Type" content="text/html"; charset="utf-8" />
	<title>Realizar Deposito</title>
	</head>
	
	<body>
<?php
$idConta=$_POST['idConta'];
$valor=$_POST['valor'];

$sql="insert into trasacoes (idConta,valor) value ('$idConta','$valor')";
$result=mysql_query($sql);

?>

<?php
$idConta=$_POST['idConta'];
$valor=$_POST['valor'];

$up = mysql_query("UPDATE conta SET saldo='$valor'  WHERE idConta=$idConta");



?>
    
asked by anonymous 08.06.2018 / 16:35

1 answer

0
1 - select tabelaSaldoAtual ,
2 -  armazena na em uma variavel  ex: var saldoAtual
3 -  pega o valor que ele depositou e salva em outra variavel. ex: var deposito
4 - NovoSaldo = saldoAtual + deposito
5 - $up = mysql_query("UPDATE conta SET saldo='$NovoSaldo'  WHERE idConta=$idConta")
    
08.06.2018 / 16:57