function to decrease the value in 1 of the table

Asked

Viewed 21 times

1

i wanted to make a function where each time it is called the active plot table is decreased by 1, follows the code I rode

     function quit() {
    $customer['parcelas'] = $customer['parcelas'] - 1;
   update('customers', $id, $customer); 

however, when I call the onclick function it simply does nothing, what’s wrong with the code?

update: I tried another type of code but it also didn’t work:

 function quit() {
         
         $sql ="UPDATE customers SET parcelas='" . $customer['parcelas'] ."'"; 
     
     }

1 answer

0

Hello,

You can do it directly in the query, this way:

function quit() {     
  $sql ="UPDATE customers SET parcelas = parcelas - 1";      
}
  • I used this function in conjunction with a variable in session with the id to be able to set Where also however it does not work, I gave a var_dump to see if the variable was correctly set and was normally, but the code was still not working

  • What is the result of the "dump" of the mounted $sql? Ex: var_dump($sql);

  • hi, sorry for the delay, it gives a string, does not give an int

  • Hello, to help you, I need more details. "doesn’t work" is quite broad. Put your quit() function in full as it is today. In your example you only have the $sql variable but without running the command in the database.

Browser other questions tagged

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