how to do an input Insert by adding the value to the database column? Mysql + php

Asked

Viewed 70 times

-1

I’m a beginner in php and am doing a tcc project of my technical course where, I have to register hours of an employee. how do I do so, by making the value add to what is already registered in the bank?

  • I believe it speaks of UPDATE.

1 answer

0

$sql = new Sql(); $sql->select("UPDATE table SET 'table fields without quotes' = bindvalue of the table plus the value to be incremented");

I’m not sure that’s clear. Try to send us more examples.

follows the code I am using to make the Insert $sql = $Pdo->prepare("INSERT INTO HORA( ID_HORA, NOME_COOPERADO, DT, HORAS_ACUMULADAS) VALUES ( NULL, :name, :dt, :hours)"); $sql->bindParam(':name', $name, PDO:PARAM_STR); $sql->bindParam('::dt', $dt, PDO:PARAM_STR); $sql->bindParam(':hours', $hours, PDO::PARAM_STR); $sql->execute();

I think you better try to do via Project, because if not you will have to build methods and extensive codes in my view. In the previous you put to return the time with increment of a variable, it can be another column in the table for this.

  • follows the code I am using to do the Insert $sql = $Pdo->prepare("INSERT INTO HORA( ID_HORA, NOME_COOPERADO, DT, HORAS_ACUMULADAS) VALUES ( NULL, :name, :dt, :hours)"); $sql->bindParam(':name', $name, PDO::PARAM_STR); $sql->bindParam(':dt', $dt, PDO::PARAM_STR); $sql->bindParam(':hours', $hours, PDO::PARAM_STR); $sql->execute();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.