php - Variable + Number to Database -


i confused great.

i trying press button add 40 sales in order add 40 need current number of sales used fetch array output number , see '40' set variable tried $varible + 40 set number. not seem working check online , anyhelp awesome!

    $query = "select `sales` `sales`";      if ($result=mysqli_query($link, $query)) {              $row = mysqli_fetch_array($result);              print_r($row);     }       if ($_post['update']) {           echo 'updating...';           $query="update `sales` set `sales` = '$row+40' `sales`.`id` = 1";          mysqli_query($link, $query);          echo '<br>successfully updated';   } else {              echo 'unsuccessful';  } 

as far query goes in mysql don't need 2 separate ones add existing data. query go follows:

update `sales` set `sales` = `sales` + 40 `sales`.`id` = 1; 

so code this...

if($_post['update']) {     echo 'updating...';     $query = "update `sales` set `sales` = `sales` + 40 `sales`.`id` = 1";     mysqli_query($link, $query);     echo '<br>successfully updated'; } else {     echo 'unsuccessful'; } 

by way, reason code failing right because $row array. have access key in array data want out of it. right you're trying sum of 40 , array object.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -