更新并从会话中将列 "downloaded" 增加 +1

UPDATE and count up column "downloaded" by +1 from a session

单击 "BUY" 按钮后,如何增加购物车会话中图像的 "downloaded" 字段?

我必须使用 UPDATE myTable SET downloaded= +1 吗?

<?php

if (!isset($_SESSION['product'])) {
    $_SESSION['product'] = array();
} 

if (isset($_GET['product'])) {    
    if (!in_array($_GET['product'], $_SESSION['product'])) {
        $_SESSION['product'][] = $_GET['product'];
    }    
    header("location: kurv.php");       
}

if (isset($_GET['delete'])) {    
    foreach ($_SESSION['product'] as $key => $val) { 
        if ($val == $_GET['delete']) {
            unset($_SESSION['product'][$key]);
        }
    }       
}    

$product = array();
$crud = new crud($con);

foreach ($_SESSION['product'] as $item) {
    $product[] = $crud->select_id('stockworld_product', 'id', $item)->fetch_object();
}    

?><form action="" method="POST"><?php
    foreach($product as $item):
        if(!$item)continue;

        ?><div style="width: 100%; height: 80px;">
            <input type="hidden" name="product[]" value="<?php echo $item->id; ?>">
            <div style="margin-left: 20px; float: left; ">                
                <h1 class="fontclass3b"><?php echo $item->title; ?></h1><br>
                <h1 class="fontclass2b">af </h1> 
                <h1 style="font-size: 30px; font-weight: 500; color: #343434;">
                    <?php echo $item->photograph; ?>
                </h1>            
            </div>
            <div style="margin-right: 20px; float: right; line-height: 80px; ">
                <a href="kurv.php?delete=<?php echo $item->id; ?>"  id="fjern">Fjern</a>
            </div>
        </div>

    <?php endforeach;?>

    <hr id="hr2" noshade>

    <button type="submit" id="add_to_basket" style="width: 30% !important;">Godkend</button>     

</form> 

UPDATE myTable SET downloaded = downloaded + 1 WHERE id = [your row id];

是的,您需要更新。

UPDATE `mytable` SET `downloads`=`downloads`+1 WHERE ????