Exemplo n.º 1
0
function save_order($dt)
{
    global $link, $basket;
    $goods = my_basket();
    $stmt = mysqli_stmt_init($link);
    $sql = "INSERT INTO orders (title, author, pubyear, price, quantity, orderid, datetime) VALUES (?, ?, ?, ?, ?, ?, ?)";
    if (!mysqli_stmt_prepare($stmt, $sql)) {
        return false;
    }
    foreach ($goods as $item) {
        mysqli_stmt_bind_param($stmt, 'ssiiisi', $item['title'], $item['author'], $item['pubyear'], $item['price'], $item['quantity'], $basket['orderid'], $dt);
        mysqli_stmt_execute($stmt);
    }
    mysqli_stmt_close($stmt);
    setcookie('basket', '', time() - 3600);
    return true;
}
Exemplo n.º 2
0
<?php

// подключение библиотек
require "inc/lib.inc.php";
require "inc/db.inc.php";
?>
<html>
<head>
    <title>Корзина пользователя</title>
</head>
<body>
    <h1>Ваша корзина</h1>
<?php 
$goods = my_basket();
if (!is_array($goods)) {
    echo "Произошла ошибка при выводе товаров.";
    exit;
}
if ($goods) {
    echo '<p>Вернуться в <a href="catalog.php">каталог</a></p>';
} else {
    echo '<p>Корзина пуста! Вернитесь в <a href="catalog.php">каталог</a></p>';
}
?>
<table border="1" cellpadding="5" cellspacing="0" width="100%">
<tr>
    <th>N п/п</th>
    <th>Название</th>
    <th>Автор</th>
    <th>Год издания</th>
    <th>Цена, грн.</th>