我目前正在开发一个在线房地产市场,并且无法从概览站点浏览,该站点将所有房地产产品显示到详细站点。
起作用的是,所有产品都显示在wohnen_haus.php上。奇怪的是,有时,当我打开一个提供站点时,会显示两个详细信息页面... php-部分一定存在问题,因为我在phpMyAdmin控制台中手动尝试了sql语句,他们带来了预期的结果。
任何想法php可能有什么问题吗?
这是我的主页:
wohnen_haus2.php
require("../model/House2.php"); //contains the class "House"
require("../func/func_properties.php"); //contains the array $properties_array that contains all offerings
require("../func/FavoriteList.php");
$House = new House2;
$House->display($house_sale);
$House->display($house_rent);
这是我定义displayHouseSale的地方:
House2.php
class House2 {
public function display ($properties_array)
{
if (isset($_GET['view_property'])) {
$property_id = $_GET['view_property'];
// IF ID IS SET, DISPLAY DESIRED PROPERTY
if (isset($properties_array[$property_id])) {
echo
"<table border='1' cellspacing='0' cellpadding='2'>
<tbody>
<tr> <td colspan='2' > <a href='#'>" . $properties_array[$property_id]['title'] . "</td> </tr>
</tbody>
</table>";
}
// IF ID IS SET WRONG, DISPLAY ERROR-MESSAGE
else
{
echo "Invalid property!";
}
}
// IF ID IS NOT SET, DISPLAY ALL PROPERTIES
else {
echo "<h3>Häuser</h3>";
// LOOP THORUGH THE ARRAY PROVIDED BY "func_properties.php"
// TO DISPLAY ALL OF THE PROPERTIES
foreach ($properties_array as $id => $property) {
echo
"<a href='wohnen_haus2.php?view_property=' " . $id . "> <h1>" . $property['title'] . "</h1> </a>";
}
}
这是我从数据库中获取数据的地方:
func_properties.php
include("../inc/config.php");
require("../inc/db_connect.php");
// Requests all houses for sale
$stmt = $dbh->prepare("
SELECT id, title, description, neighbourhood, vacant_from, street, housenumber, postalcode, city, construction_year, rooms, levels, bathrooms, kitchens, living_space, agent, image,
property_size, house_type,
deposit, pets, net_rent, heated_rent
FROM tbl_OFFERING o, tbl_PROPERTY_TYPE_house pth, tbl_OFFERING_FORMAT_rental ofr
WHERE o.id = ofr.offering_id
AND o.id = pth.offering_id;
");
$stmt->execute();
$house_rent = $stmt->fetchAll(PDO::FETCH_ASSOC);
//Requests all houses for rent
$stmt = $dbh->prepare("
SELECT
id, title, description, neighbourhood, vacant_from, street, housenumber, postalcode, city, construction_year, rooms, levels, bathrooms, kitchens, living_space, agent, image,
property_size, house_type,
sales_price, brokers_commission
FROM tbl_OFFERING o, tbl_PROPERTY_TYPE_house pth, tbl_OFFERING_FORMAT_sale ofs
WHERE o.id = ofs.offering_id
AND o.id = pth.offering_id");
$stmt->execute();
$house_sale = $stmt->fetchAll(PDO::FETCH_ASSOC);