* Created by PhpStorm.
 * User: samuel
 * Date: 3/25/2016
 * Time: 12:49 AM
 */
include_once 'Item.php';
include_once 'render_config.php';
session_start();
$item = new Item();
$mail = isset($_SESSION['email']) ? $_SESSION['email'] : '';
//$mail = '*****@*****.**';
$row = $item->getItemsBought($mail);
$cust_items = $row->fetch_array(MYSQLI_ASSOC);
$file = $cust_items['items_bought'];
if (!file_exists($file)) {
    //    die("File not found");
    header('Location: ./error.html');
} else {
    $my_file = fopen($file, "r");
    //or die("Unable to open file!");
    //
    while (!feof($my_file)) {
        $id = fgets($my_file) . '<br>';
        $r = $item->getSkirtDetails($id);
        $addSkirt = $r->fetch_array(MYSQLI_ASSOC);
        $array['bought'][$id] = ['item' => $addSkirt['skirt_id'], 'skirt_name' => $addSkirt['skirt_name'], 'brand_name' => $addSkirt['brand_name'], 'pic' => $addSkirt['pic'], 'price' => $addSkirt['price']];
    }
}
fclose($my_file);
//print_r($array['bought']);
echo $twig->render('history.twig', ['history' => $array['bought']]);
<?php

/**
 * Created by PhpStorm.
 * User: samuel
 * Date: 3/20/2016
 * Time: 3:47 PM
 */
session_start();
include_once 'Item.php';
include_once 'render_config.php';
$item = new Item();
$sk_id = null;
$total = 0;
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $skirt = $item->getSkirtDetails($id);
    $sk_details = $skirt->fetch_array(MYSQLI_ASSOC);
    if (isset($_GET['action'])) {
        $sk_id = $_GET['id'];
        //    $action = $_GET['action'];
        if (!isset($_SESSION['cart'][$sk_id])) {
            $sk_d = $item->getSkirtDetails($sk_id);
            $addSkirt = $sk_d->fetch_array(MYSQLI_ASSOC);
            $_SESSION['cart'][$sk_id] = ['item' => $addSkirt['skirt_id'], 'skirt_name' => $addSkirt['skirt_name'], 'brand_name' => $addSkirt['brand_name'], 'quantity' => 1, 'pic' => $addSkirt['pic'], 'qty' => $addSkirt['qty'], 'price' => $addSkirt['price'], 'total' => $addSkirt['price']];
            header('Location: index.php');
        }
    }
}
//print_r($_SESSION['cart']);
echo $twig->render('product-details.twig', ['skirt_name' => $sk_details['skirt_name'], 'skirt_id' => $sk_details['skirt_id'], 'skirt_brand_name' => $sk_details['brand_name'], 'skirt_price' => $sk_details['price'], 'skirt_qty' => $sk_details['qty'], 'skirt_pic' => $sk_details['pic']]);