diff --git a/db.php b/db.php index 5b9a6b4..b0d1a70 100644 --- a/db.php +++ b/db.php @@ -5,7 +5,7 @@ function fetchCats() { $password = 'student'; $schema = 'ibuy'; $pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password); - $stmt = $pdo->prepare('SELECT * FROM categories'); + $stmt = $pdo->prepare('SELECT * FROM category'); $stmt->execute(); $cats = $stmt->fetchAll(); diff --git a/layout.php b/layout.php index 2ca76ee..f93976d 100644 --- a/layout.php +++ b/layout.php @@ -36,7 +36,7 @@ require_once 'db.php'; '. $cat['category_name'] .''; + echo '
  • '. $cat['name'] .'
  • '; } ?>
  • diff --git a/public/index.php b/public/index.php index 88e59d8..c374082 100644 --- a/public/index.php +++ b/public/index.php @@ -25,12 +25,12 @@ function populateList($category) { //TODO: This will need to be updated to popul $pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password); if ($category === 'Latest Listings') { - $stmt = $pdo->prepare('SELECT * FROM listings WHERE listing_deadline > "'. date("Y-m-d H:i:s"). '" ORDER BY listing_deadline DESC'); + $stmt = $pdo->prepare('SELECT * FROM auction WHERE endDate > "'. date("Y-m-d H:i:s"). '" ORDER BY endDate DESC'); $stmt->execute(); $listings = $stmt->fetchAll(); } else { - $stmt = $pdo->prepare('SELECT * FROM listings WHERE listing_category = (SELECT category_id FROM categories WHERE category_name = :listing_category)'); + $stmt = $pdo->prepare('SELECT * FROM auction WHERE categoryId = (SELECT category_id FROM category WHERE name = :listing_category)'); $values = [ 'listing_category' => $category ]; @@ -48,9 +48,9 @@ function populateList($category) { //TODO: This will need to be updated to popul $output .= '
  • product name
    -

    '. $listing['listing_name'] .'

    -

    '. $listing['listing_category'] .'

    -

    '. $listing['listing_description'] .'

    +

    '. $listing['name'] .'

    +

    '. $listing['categoryId'] .'

    +

    '. $listing['description'] .'

    Current bid:'. $stmt->fetch()['MAX(amount)'] .'

    More >>
    diff --git a/public/listing.php b/public/listing.php index 72b744c..5768a09 100644 --- a/public/listing.php +++ b/public/listing.php @@ -14,16 +14,16 @@ function populateContent() { $schema = 'ibuy'; $pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password); - $stmt = $pdo->prepare('SELECT * FROM listings WHERE listing_id= :listing_id'); + $stmt = $pdo->prepare('SELECT * FROM auction WHERE listing_id= :listing_id'); $values = [ 'listing_id' => $_GET['listing_id'] ]; $stmt->execute($values); $listing = $stmt->fetch(); - $stmt = $pdo->prepare('SELECT * FROM categories WHERE category_id = :category_id'); + $stmt = $pdo->prepare('SELECT * FROM category WHERE category_id = :category_id'); $values = [ - 'category_id' => $listing['listing_category'] + 'category_id' => $listing['categoryId'] ]; $stmt->execute($values); $category = $stmt->fetch(); @@ -37,25 +37,25 @@ function populateContent() { $stmt = $pdo->prepare('SELECT * FROM users WHERE email = :email'); $values = [ - 'email' => $listing['listing_email'] + 'email' => $listing['email'] ]; $stmt->execute($values); $user = $stmt->fetch(); $output = ' product name
    -

    '. $listing['listing_name'] .'

    -

    '. $category['category_name'] .'

    +

    '. $listing['name'] .'

    +

    '. $category['name'] .'

    Auction created by '. $user['first_name'].$user['last_name'] .'

    Current bid: '. $bid['MAX(amount)'] .'

    - +
    -

    '. $listing['listing_description'] .'

    +

    '. $listing['description'] .'