Пример #1
0
function loadApartment($apartment_id)
{
    $connection = mysqli_connect("localhost", "root", "", "rental_27485506");
    if (mysqli_connect_errno()) {
        print "Connection error: " . mysqli_connect_error();
        exit;
    }
    $query = "SELECT * FROM `apartments` WHERE `apartment_id`='{$apartment_id}'";
    $result = mysqli_query($connection, $query);
    if (mysqli_num_rows($result) == 1) {
        // Info about apartment
        $row = mysqli_fetch_assoc($result);
        $user_id = $row['user_id'];
        $adTitle = $row['adTitle'];
        $address = $row['address'];
        $city = $row['city'];
        $postalcode = $row['postalcode'];
        $nb_rooms = $row['nb_rooms'];
        $nb_bathrooms = $row['nb_bathrooms'];
        $monthly_fee = $row['monthly_fee'];
        $availability = $row['availability'];
        $personal_msg = $row['personal_msg'];
        // Get info about the owner of the apartment
        $query = "SELECT * FROM `accounts` WHERE `user_id`='{$user_id}'";
        $result = mysqli_query($connection, $query);
        $row = mysqli_fetch_assoc($result);
        $firstname = $row['firstname'];
        $lastname = $row['lastname'];
        $email = $row['email'];
        $phonenumber = $row['phonenumber'];
        print "<h2>" . $adTitle . "</h2>";
        print "<p>\n\t\t\t\t\t<a href='#apartmentDescription'>Apartment Information</a> | <a href='#landlordDescription'>Landlord Contact Information</a> | <a href='#tenantDescription'>Ideal Tenant</a>\n\t\t\t\t\t</p>";
        print "<p>";
        print "\n\t\t\t\t<div class='userInfoPanel'>\n\t\t\t\t\t<div class='userInfoBox'>\n\t\t\t\t\t\t<h3 id='apartmentDescription'>Apartment Information</h3>\n\t\t\t\t\t\t<table class='table table-hover' id='userInformation'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Address</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t{$address}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>City</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t{$city}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Postal code</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t{$postalcode}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Number of rooms</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t{$nb_rooms}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Number of bathrooms</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t{$nb_bathrooms}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Monthly fee</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t{$monthly_fee}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Availability</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t{$availability}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Message to those interested</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t{$personal_msg}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Link to this apartment page</th>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<a href='http://localhost/apartmentRenting/viewApartment.php/?apartment_id={$apartment_id}'>http://localhost/apartmentRenting/viewApartment.php/?apartment_id={$apartment_id}</a>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class='userInfoBox'>\n\t\t\t\t\t\t<h3 id='landlordDescription'>Landlord Contact Information</h3>\n\t\t\t\t\t\t<table class='table table-hover' id='userInformation'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t\t\t\t<td>{$firstname} {$lastname}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>E-mail</th>\n\t\t\t\t\t\t\t\t<td>{$email}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Phone Number</th>\n\t\t\t\t\t\t\t\t<td>{$phonenumber}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class='userInfoBox'>\n\t\t\t\t\t\t<h3 id='tenantDescription'>Ideal Tenant Description</h3>";
        printOwnerPreferences($user_id);
        print "</div>\n\t\t\t\t</div>\n\t\t\t\t";
        print "</p>";
    } else {
        print "<h2>Error</h2>";
        print "<p>Requested apartment could not be found</p>";
    }
}
}
?>
						</p>
					</div>
					
					<div class="userInfoBox">
						<h3 class="center" id='rentingPreferences'>Renting preferences</h3>
						<p class='center'>
							<?php 
if ($type == '0') {
    // tenant
    print "<a href='http://localhost/apartmentRenting/tenantRentalPref.php'>Edit my renting preferences</a><br>";
    printTenantPreferences($user_id);
} elseif ($type == '1') {
    // owner
    print "<a href='http://localhost/apartmentRenting/ownerRentalPref.php'>Edit my renting preferences</a><br>";
    printOwnerPreferences($user_id);
}
?>
						</p>
					</div>
				</div>
			</article>
		</div>
		
		<footer>
		</footer>
		
		<script type="text/javaScript" src="http://localhost/apartmentRenting/js/headerFooter.js"></script>
	</body>
</html>>