I want to subtract the follower count of a user by 1, or increase it by but I don't want to do this:
$sql = $conn->prepare('SELECT folllower_num FROM users WHERE user_id = ?'); $sql->execute($user_id)); //then grab the follower_num value, save it to a variable, and subtract 1 //from it and then: $sql = $conn->prepare('UPDATE users SET follower_num = ? WHERE user_id = ?;'); $sql->execute($newfollowercount, $user_id));
or something like that. To me this seems bad to do because while the value is saved into this code and then changed and put back into the database, someone else could have followed or unfollowed and then the number becomes incorrect. Is there another way I can do this?