如何增加"已下载"点击"购买"我购物车会话中的图片字段按钮?
我必须使用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>
答案 0 :(得分:0)
UPDATE myTable SET已下载=已下载+ 1 WHERE = [您的行ID];
答案 1 :(得分:0)
是的,您需要更新。
UPDATE `mytable` SET `downloads`=`downloads`+1 WHERE ????