diff --git a/functions.php b/functions.php
index 8fddea8..3d08eb1 100644
--- a/functions.php
+++ b/functions.php
@@ -27,4 +27,29 @@ function startDB() {
$pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password);
return $pdo;
}
+
+function checkListing() {
+ if (!isset($_GET['listing_id'])) {
+ echo '';
+ }
+}
+
+function getListing() {
+ $pdo = startDB();
+ $stmt = $pdo->prepare('SELECT * FROM auction WHERE listing_id = :listing_id');
+ $values = [
+ 'listing_id' => $_GET['listing_id']
+ ];
+ $stmt->execute($values);
+ return $stmt->fetch();
+}
+
+function populateCatSelect() {
+ $cats = fetchCats();
+ $output = '';
+ foreach ($cats as &$cat) {
+ $output .= '';
+ }
+ return $output;
+}
?>
\ No newline at end of file
diff --git a/public/account/addAuction.php b/public/account/addAuction.php
index cf90513..f3617c8 100644
--- a/public/account/addAuction.php
+++ b/public/account/addAuction.php
@@ -13,7 +13,7 @@ $pdo = startDB();
$pageContent = '
Add auction
';
+require '../../layout.php';
+
+if(isset($_POST['submit'])) {
+ $stmt = $pdo->prepare('UPDATE auction SET title = :title, categoryId = :categoryId, endDate = :endDate, description = :description');
+ $values = [
+ 'title' => $_POST['title'],
+ 'categoryId' => intval($_POST['category']),
+ 'endDate' => $_POST['endDate'],
+ 'description' => $_POST['description']
+ ];
+ $stmt->execute($values);
+ echo '';
+}
+
+?>
\ No newline at end of file
diff --git a/public/listing.php b/public/listing.php
index c40f20b..c4ed9cf 100644
--- a/public/listing.php
+++ b/public/listing.php
@@ -7,19 +7,11 @@ $pageContent = 'Product Page
require '../layout.php';
-if (!isset($_GET['listing_id'])) {
- echo '';
-}
+checkListing();
function populateContent() {
$pdo = startDB();
-
- $stmt = $pdo->prepare('SELECT * FROM auction WHERE listing_id= :listing_id');
- $values = [
- 'listing_id' => $_GET['listing_id']
- ];
- $stmt->execute($values);
- $listing = $stmt->fetch();
+ $listing = getListing();
$stmt = $pdo->prepare('SELECT * FROM category WHERE category_id = :category_id');
$values = [
@@ -48,7 +40,7 @@ function populateContent() {
'. $category['name'] .'
Auction created by '. $user['first_name'].$user['last_name'] .'
Current bid: '. $bid['MAX(amount)'] .'
-
+