fully populated listings by db
This commit is contained in:
parent
978753bfae
commit
f83242e7ae
|
|
@ -14,20 +14,41 @@ function populateContent() {
|
|||
$password = 'student';
|
||||
$schema = 'ibuy';
|
||||
$pdo = new PDO('mysql:dbname=' . $schema . ';host=' . $server, $username, $password);
|
||||
|
||||
$stmt = $pdo->prepare('SELECT * FROM listings 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');
|
||||
$values = [
|
||||
'category_id' => $listing['listing_category']
|
||||
];
|
||||
$stmt->execute($values);
|
||||
$category = $stmt->fetch();
|
||||
|
||||
$stmt = $pdo->prepare('SELECT MAX(amount) FROM bids WHERE listing_id = :listing_id');
|
||||
$values = [
|
||||
'listing_id' => $listing['listing_id']
|
||||
];
|
||||
$stmt->execute($values);
|
||||
$bid = $stmt->fetch();
|
||||
|
||||
$stmt = $pdo->prepare('SELECT * FROM users WHERE email = :email');
|
||||
$values = [
|
||||
'email' => $listing['listing_email']
|
||||
];
|
||||
$stmt->execute($values);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
$output = ' <img src="product.png" alt="product name">
|
||||
<section class="details">
|
||||
<h2>'. $listing['listing_name'] .'</h2>
|
||||
<h3>'. $listing['listing_category'] .'</h3>
|
||||
<p>Auction created by <a href="#">User.Name</a></p>
|
||||
<p class="price">Current bid: £123.45</p>
|
||||
<h3>'. $category['category_name'] .'</h3>
|
||||
<p>Auction created by <a href="#">'. $user['first_name'].$user['last_name'] .'</a></p>
|
||||
<p class="price">Current bid: '. $bid['MAX(amount)'] .'</p>
|
||||
<time>Time left:'. (strtotime($listing['listing_deadline']) - strtotime(date('Y-m-d H:i:s')))/60 .'</time>
|
||||
<form action="#" class="bid">
|
||||
<input type="text" name="bid" placeholder="Enter bid amount" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue