i have column inside user table named paircount
has value of 2 default, whenever action occur, want value minus 1 (1). wrote following code
<?php session_start(); require_once './include/constants.php'; require_once './include/databaseconn.php'; require_once './vendor/autoload.php'; require_once './include/user.php'; require_once './include/level.php'; use \phputil\json; $user = user::getcurrentuser(); $db = new databaseconn(); $link = $db->connect(); $sql = "update users set `payee-1` = null, status = ?,`paircount` = ? `payee-1` = ?"; $stmt = $link->prepare($sql); $stmt->bind_param('sss', $status, $paircount, $payee1); $status = pair; //here did calculation, given me error $paircount = $paircount (-1); $payee1 = ($user->getusername()); $res = $stmt->execute(); $stmt->store_result(); if ($res) { echo "<h1>congrate have unsubscribe pay person"; header('refresh: 3;url=icant3.php'); } else { echo 'undone'; }
it possible in sql query.
update users set `payee-1` = null, status = ?, `paircount` = paircount - 1 `payee-1` = ?
then don't need $paircount
variable in php code.
Comments
Post a Comment