edits
This commit is contained in:
parent
fb76234eb8
commit
a90bda3896
|
|
@ -18,12 +18,13 @@ $pageContent = '<h1>Edit Auction</h1>
|
|||
require '../../layout.php';
|
||||
|
||||
if(isset($_POST['submit'])) {
|
||||
$stmt = $pdo->prepare('UPDATE auction SET title = :title, categoryId = :categoryId, endDate = :endDate, description = :description');
|
||||
$stmt = $pdo->prepare('UPDATE auction SET title = :title, categoryId = :categoryId, endDate = :endDate, description = :description WHERE listing_id = :listing_id');
|
||||
$values = [
|
||||
'title' => $_POST['title'],
|
||||
'categoryId' => intval($_POST['category']),
|
||||
'endDate' => $_POST['endDate'],
|
||||
'description' => $_POST['description']
|
||||
'description' => $_POST['description'],
|
||||
'listing_id' => $listing['listing_id']
|
||||
];
|
||||
$stmt->execute($values);
|
||||
echo '<script>window.location.href = "../listing.php?listing_id='.$listing['listing_id'].'";</script>';
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ function populateList($category) {
|
|||
$pdo = startDB();
|
||||
$output = '';
|
||||
if ($category === 'Latest Listings') {
|
||||
$stmt = $pdo->prepare('SELECT * FROM auction WHERE endDate > "'. date("Y-m-d H:i:s"). '" ORDER BY endDate DESC');
|
||||
$stmt = $pdo->prepare('SELECT * FROM auction WHERE endDate > "'. date("Y-m-d H:i:s"). '" ORDER BY endDate ASC');
|
||||
$stmt->execute();
|
||||
$listings = $stmt->fetchAll();
|
||||
}
|
||||
|
|
@ -35,6 +35,15 @@ function populateList($category) {
|
|||
}
|
||||
|
||||
foreach ($listings as &$listing) {
|
||||
|
||||
|
||||
$stmt = $pdo->prepare('SELECT * FROM category WHERE category_id = :category_id');
|
||||
$values = [
|
||||
'category_id' => $listing['categoryId']
|
||||
];
|
||||
$stmt->execute($values);
|
||||
$listCat = $stmt->fetch()['name'];
|
||||
|
||||
$stmt = $pdo->prepare('SELECT MAX(amount) FROM bids WHERE listing_id = :listing_id');
|
||||
$values = [
|
||||
'listing_id' => $listing['listing_id']
|
||||
|
|
@ -45,7 +54,7 @@ function populateList($category) {
|
|||
<img src="assets/product.png" alt="product name">
|
||||
<article>
|
||||
<h2>'. $listing['title'] .'</h2>
|
||||
<h3>'. $listing['categoryId'] .'</h3>
|
||||
<h3>'. $listCat .'</h3>
|
||||
<p>'. $listing['description'] .'</p>
|
||||
<p class="price">Current bid:'. $stmt->fetch()['MAX(amount)'] .'</p>
|
||||
<a href="listing.php?listing_id='. $listing['listing_id'] .'" class="more auctionLink">More >></a>
|
||||
|
|
|
|||
Loading…
Reference in New Issue