-
Not sure what to do....
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>
-
Seems to be working now, is that correct?
-
Oh sorry i forgot to tell you that the link I pasted was an example on how I wanted my script to be.
-
Okay, well, you need to include the ID value of the apartment in the link to the detail page. On the detail page, you would query your database for the apartment where the ID field = the ID that you passed to the page. The easiest way to do it is to put the ID in the querystring of the URL. A more secure way to do it is to build a hidden form and submit the form via javascript.
That's how I do it on the following site if you want another example to look it: http://www.lastfrontierautosales.com
Here's an example of a site my company did that passes the ID via the querystring. The ID of the house is referenced by the key "L": http://www.cbba.com
-
Thanks for your help. Im looking for the same thing as you got on your site.
I tried to make an ID for each apartment through the loop, but think i was way off. Could you show me where I should make an ID for each apartment that goes through the loop?
Thanks
-
1) Can I see a row of " foto_url " just to know exactly what you stored in your DB.
2) " href=\"ledig.php?page=1 " must be dynamic.. I mean, you must send an info extracted from your query, an ID, as Rawhide said.
Let's say : In your query you have an ID for each appartment(it must be..), you may have to call another php page (href=\"otherpage.php?apt=$row-> apartmentNr " ).
And, in that otherpage.php, create a query like this: $q= "select * from apartment where apartmentNr=$GET['apt']"
Good luck
-
1) I have pasted a picture from table "apartment". Sorry that the table is in norwegian. Short translations:
First column "leilighetNr" is the primary key for apartment (ID).
Second column "overskrift" is a short description for the apartment.
third column "adresse" is address
fourth column "etasje" is nr of floors
fifth column "room" is nr of rooms.
sixth column "kvm" is size
seventh column "bilde_url" = foto_url
etc....
last column "eiendomsNr" is proprtyNr that is a foreign key to table property.
http://forums.databasejournal.com/clear.gif
2)
I get this error when I implement your example:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /usr/local/apache2/htdocs/hrdrift/ledig/otherpage.php on line 9
Last edited by sirikit; 05-01-2005 at 10:56 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|