'.$pageHeading.' '; require '../layout.php'; function populateList($category) { //TODO: This will need to be updated to populate from the database $output = ''; $server = 'mysql'; $username = 'student'; $password = 'student'; $schema = 'ibuy'; $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->execute(); $listings = $stmt->fetchAll(); } else { $stmt = $pdo->prepare('SELECT * FROM listings WHERE listing_category = :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['listing_name'] .'

    '. $listing['listing_category'] .'

    '. $listing['listing_description'] .'

    Current bid:'. $stmt->fetch() .'

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