<?php
Class ViewPosting {
protected $id;
protected $img;
function __construct($id) {
$this->id = $id;
$this->getPosting();
}
function getPosting() {
$postingResource = mysql_query("SELECT * FROM Postings WHERE id='$this->id' LIMIT 1");
while ($row = mysql_fetch_assoc($postingResource)) {
$this->name = $row['name'];
$this->description = $row['description'];
$this->price = $row['price'];
$this->specificLocation = $row['specificLocation'];
$this->cityID = $row['cityID'];
$this->userID = $row['userID'];
$this->category = $row['category'];
$this->datePosted = $row['datePosted'];
}
}
function displayImages() {
$imageResource = mysql_query("SELECT * FROM Images WHERE postingID='$this->id'");
while ($imageRow = mysql_fetch_assoc($imageResource)) {
$this->imageArray[] = $imageRow['imageName'];
}
if (isset($this->imageArray[0])) {
foreach($this->imageArray as $img) echo "<img src='postingImages/$img'/>";
}
}
}
?>