简体   繁体   中英

how to subtract a variable stored in database

I'm trying to minus the variable from the database I stored. Being trying my luck but unable to solve it. So I doing a recruiting process for example I opened 2 vacancy for this job position title and job type then when someone apply and I hired him/her the vacancy must minus one in the database. Thanks in advance! So this is my code:

<?php
    if ($applied_position_title == $position_title && $applied_job_type == $job_type) {
        echo $vacancy;
        $output = --$vacancy;
        echo $output;
    }
    $query_status = "UPDATE job_opening SET closing_date = DATE('$newdate'), creator_id = '$creator_id', job_opening_status = 'Closed', vacancy = '$output' WHERE '$job_accepted' = 'Yes' AND '$applied_position_title' = position_title AND '$applied_job_type' = job_type";
    $result_status = mysqli_query($link, $query_status) or die(mysqli_error($link));
    echo $query_status;
?>

进行如下更新查询:

UPDATE `your_table` SET `filed_name` = (`filed_name` - 1) WHERE `some_id` = 1

在查询中尝试vacancy = (vacancy-1)

$query_status = "UPDATE job_opening SET closing_date = DATE('$newdate'), creator_id = '$creator_id', job_opening_status = 'Closed', vacancy = (vacancy-1) WHERE '$job_accepted' = 'Yes' AND '$applied_position_title' = position_title AND '$applied_job_type' = job_type";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM