This is a realestate database. If you look at this page you can see all the available apartments. I got that to work, but now I want to go to a specific appartment like pressing the hyperlink "Majorstua- 2-roms" (the link i pasted) and receive the information. Here you receive information for that specific apartment you wanted to have a look on, but my problem is that it shows all information for all available apartments.
I just wanted to test if it worked with a picture, but no luck at all. Displays pictures for all available apartments. 1 apartment row has a unique picture. Think I need a new "SELECT" query in case '1'.
I got 3 different tables in my DB. Property, Apartment and Tenant.
Some suggestions?
I have pasted my whole code now, but some is in Norwegian. Have tried to translate most of it:
PHP Code:
<html>
<head>
<title>Free apartments</title>
</head>
<body>
<h1><center>Displays apartments that are available.</center></h1> <br>
<br>
<?
include("database.php");
function available()
{
global $conn;<
$Names = array( 1=> "Kongleveien 26", 2 => "Mosseveien 5", 3=> "karlslia 32", 6=> "Drammensveien 2" ); //Fill out this array as shown with place names
$q = "SELECT * FROM apartment LEFT JOIN tenant ON tenant.apartmentNr = apartment.apartmentNr WHERE tenant.apartmentNr IS NULL GROUP BY apartment.propertyNr";
$result = mysql_query($q, $conn) or die(mysql_error());
$CurrentProp = 0;
echo "<table>";
while ($row = mysql_fetch_object($result))
{
while($row-> proprtyNr > $CurrentProp)
{
$CurrentProp++;
if($row-> propertyNr > $CurrentProp && $CurrentProp == $row-> eiendomsNr)
{
echo "<tr><td colspan=4>No available</td></tr>";
}
elseif($CurrentProp == $row-> propertyNr)
{
$foto = $row->foto_url;
switch($_GET['page'])
{
case '1':
echo "<table><tr><td><img src=$foto><br></td></tr>";
break;
default:
echo "<tr><td colspan=4><b>{$Names[$CurrentProp]}:</b></td></tr><tr bgcolor=#081C5B><td><font color=#FFFFFF>Bilde</td><td><font color=#FFFFFF>Address</td>
<td><font color=#FFFFFF>room</td>
<td><font color=#FFFFFF>price</td>
</tr>
<tr>
<td><center><img src=$foto></td><td><center><a href=\"ledig.php?page=1\">{$row->address}</a></td><td><center>{$row->room}</td><td><center>{$row->price}</td><p></tr>";
break;
}
}
else
{
}
}
echo "<tr>";
}
echo "</table>";
}
?>
</body>
</html>