'.$pageHeading.' '; require '../layout.php'; 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->execute(); $listings = $stmt->fetchAll(); } else { $stmt = $pdo->prepare('SELECT * FROM auction WHERE categoryId = (SELECT category_id FROM category WHERE name = :listing_category)'); $values = [ 'listing_category' => $category ]; $stmt->execute($values); $listings = $stmt->fetchAll(); } foreach ($listings as &$listing) { $stmt = $pdo->prepare('SELECT MAX(amount) FROM bids WHERE listing_id = :listing_id'); $values = [ 'listing_id' => $listing['listing_id'] ]; $stmt->execute($values); $output .= '
  • product name

    '. $listing['title'] .'

    '. $listing['categoryId'] .'

    '. $listing['description'] .'

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

    More >>
  • '; } return $output; } ?>