Введение в программирование на PHP5


Example.I.11


<?php session_start(); $ItemNumber = $_GET[ItemNumber]; $Category = $_GET[Category]; $Criterion =$_GET[Criterion]; $OrderNo = $_SESSION[OrderNo]; $OrderDate = date('n/d/y');

if ($_POST[BuyButton] == "Buy Now") {

$OrderItem = $_GET[OrderItem]; $conn2 = odbc_connect('Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\inetpub\wwwroot\PHPTutorial\Ecommerce\databases\ecommerce.mdb','',''); $sqlCart = "SELECT OrderNo,OrderItem FROM ShopCart WHERE OrderNo ='$OrderNo'"; $rsCart = odbc_exec($conn2,$sqlCart);

while ($row = odbc_fetch_array($rsCart)) { if ($row[OrderNo] == $OrderNo && $row[OrderItem] == $OrderItem) { $update = true;

}

}

if (!$update) { $sqlInsert = "INSERT INTO ShopCart (OrderNo,OrderItem,OrderDate,OrderQuantity) Values ('$OrderNo', '$OrderItem','$OrderDate,1)"; $rsInsert = odbc_exec($conn2,$sqlInsert); } else {

$sqlUpdate = "Update ShopCart SET OrderQuantity = OrderQuantity + 1 WHERE OrderNo = '$OrderNo' AND OrderItem = '$OrderItem'"; $rsUpdate = odbc_exec($conn2,$sqlUpdate); } header("Location:shopcart.php"); } ?>

Пример I.11.

Закрыть окно




Начало  Назад  Вперед



Книжный магазин