From a90bda3896699fa4c77df4fec35292444f920410 Mon Sep 17 00:00:00 2001
From: Joshua Perry <45966243+jpez-development@users.noreply.github.com>
Date: Sun, 20 Nov 2022 17:51:10 +0000
Subject: [PATCH] edits
---
public/account/editAuction.php | 5 +++--
public/index.php | 13 +++++++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/public/account/editAuction.php b/public/account/editAuction.php
index 7ad0ea9..f8de26d 100644
--- a/public/account/editAuction.php
+++ b/public/account/editAuction.php
@@ -18,12 +18,13 @@ $pageContent = '
Edit Auction
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 '';
diff --git a/public/index.php b/public/index.php
index b45cb8c..139ebfa 100644
--- a/public/index.php
+++ b/public/index.php
@@ -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) {
'. $listing['title'] .'
- '. $listing['categoryId'] .'
+ '. $listCat .'
'. $listing['description'] .'
Current bid:'. $stmt->fetch()['MAX(amount)'] .'
More >>