function sell() { echo "\n <div class='row'>\n <div class='col-sm-5'>\n <h2>Your live auctions:</h2>\n <table class='table table-condensed'>\n <thead>\n <tr>\n <th>Item Name</th>\n <th>Time Remaining</th>\n <th>Bids</th>\n <th>View</th>\n </tr>\n </thead>\n <tbody>"; $db = Database::connect(); $id = $_SESSION['id']; $sql = "SELECT auctionID,itemName,endTime FROM item,auction WHERE item.itemID = auction.Item_itemID AND Seller_sellerID = {$id} AND auction.endTime>now()"; foreach ($db->query($sql) as $row) { $i = 0; $aucID = $row['auctionID']; $sqlbid = "SELECT * FROM bid WHERE Auction_auctionID = {$aucID}"; foreach ($db->query($sqlbid) as $r) { $i++; } echo "<tr><td>" . $row["itemName"] . "</td><td>" . timeRem($row["endTime"]) . "</strong></td><td>{$i}</td><td><a href='auction.php?id={$aucID}'><button type='button' class='btn btn-success'>View</button></a></td></tr>"; } echo "\n </tbody>\n </table>\n </div>\n <div class='col-sm-3'>\n <a href='create_post.php'><button class='center-block btn btn-default'><span class='glyphicon glyphicon-plus' ></span> Create New Auction</button> </a>\n <a href='account.php'><button class='center-block btn btn-default'><span class='glyphicon glyphicon-cog' ></span> See Your Account</button> </a>\n </div>\n <div class='col-sm-4'>\n <h2>Ended Auctions</h2>\n <table class='table table-condensed'>\n <thead>\n <tr>\n <th>Item Name</th>\n <th>Time Ended</th>\n <th>Sale Price</th>\n <th>View</th>\n <th>Paid</th>\n </tr>\n </thead>\n <tbody>"; $db = Database::connect(); $id = $_SESSION['id']; $sql = "SELECT auctionID,itemName,endTime,currentPrice,paid FROM item,auction WHERE item.itemID = auction.Item_itemID AND Seller_sellerID = {$id} AND auction.endTime<now() ORDER BY auction.endTime DESC"; foreach ($db->query($sql) as $row) { $i = 0; $aucID = $row['auctionID']; if ($row['paid']) { $paidimg = "<span class='glyphicon glyphicon-ok'></span>"; } else { $paidimg = "<span class='glyphicon glyphicon-remove'></span>"; } $sqlbid = "SELECT * FROM bid WHERE Auction_auctionID = {$aucID}"; foreach ($db->query($sqlbid) as $r) { $i++; } if ($i == 0) { $salePrice = "Not Sold"; } else { $salePrice = $row["currentPrice"]; } echo "<tr><td>" . $row["itemName"] . "</td><td>" . $row["endTime"] . "</td><td>" . $salePrice . "</td><td><a href='auction.php?id={$aucID}'><button type='button' class='btn btn-success'>View</button></a></td><td>{$paidimg}</td></tr>"; } echo "\n </tbody>\n </table>\n </div>\n </div>\n\n\n\n\n\n\n"; }
$search = '%' . $_GET['search'] . '%'; } else { $search = '%'; } if (isset($_GET['order_by'])) { $order_by = "ORDER BY " . $_GET['order_by']; if (isset($_GET['order'])) { $order_by = $order_by . " " . $_GET['order']; } } else { $order_by = 'ORDER BY auction.endTime ASC'; } $sql = "SELECT auction.auctionID, item.imgLoc, item.itemName,\n\t\t\t\t\t\t\tauction.currentPrice, auction.endTime\n\t\t\t\t\t\t\tFROM auction,item\n\t\t\t\t\t\t\tWHERE auction.Item_itemID = item.itemID\n\t\t\t\t\t\t\tAND auction.endTime > Now() AND item.Categorisation_categoryName\n\t\t\t\t\t\t\tLIKE '{$cat}' AND auction.currentPrice>{$min} AND auction.currentPrice<{$max}\n\t\t\t\t\t\t\tAND item.itemName LIKE '{$search}'\n\t\t\t\t\t\t\t{$order_by}"; foreach ($db->query($sql) as $row) { $aucID = $row['auctionID']; echo "<tr > <td><a href='auction.php?id={$aucID}'><img width = '85%'\n\t src=" . $row['imgLoc'] . "></a></td><td><a href='auction.php?id={$aucID}'>" . $row["itemName"] . "</a></td><td>£" . $row["currentPrice"] . "</td><td>" . timeRem($row["endTime"]) . "</strong></td></tr>"; } Database::disconnect(); ?> </tbody> </table> </div> </div> </body>
<div class="col-sm-4" > <?php echo "<img src='{$imgLoc}' class='img-rounded' alt='{$itemName}' style='border: ridge; max-height:100%; width:100%'>"; ?> </div> <div class="col-sm-8"> <div class="row"> <div class="col-sm-7"> <?php if ($_SESSION['loggedIn'] && $_SESSION['usertype'] == 'buyer' && $ongoing) { echo "\n <form class='form-inline' role='form' action='bid.php?id={$auctionID}' method='post' style='margin-bottom: 2%' >\n <div class='form-group'>\n <label for='bidAmt'>Bid Amount: £</label>\n <input pattern='[0-9]*[.]?[0-9]?[0-9]?' class='form-control' id='bidAmt' name='bidAmt'>\n </div>\n <button type='submit' class='btn btn-default'>Submit</button>\n </form>"; } ?> <table class="table"> <?php echo "<tr><td>Time Remaining: </td><td> " . timeRem($endTime) . "</strong></td></tr>"; if ($reservePrice > $currentPrice) { echo "<tr style='background-color: #d5d5d5'><td><h4>Current Price: </h4></td><td> <h4><strong style='color: red'>{$currentPrice}</strong></h4>(Reserve price not met)</td></tr>"; } else { echo "<tr style='background-color: #d5d5d5'><td><h4>Current Price: </h4></td><td> <h4><strong>{$currentPrice}</strong></h4></td></tr>"; } $sql = "SELECT count(bidAmount) FROM bid WHERE Auction_auctionID = {$auctionID} "; $db = Database::connect(); foreach ($db->query($sql) as $row) { $bids = $row['count(bidAmount)']; } Database::disconnect(); if (!isset($bids)) { $bids = 0; } echo "<tr><td>Bids: </td><td><strong>{$bids}</strong></td></tr> ";