-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult2.php
More file actions
74 lines (66 loc) · 2.22 KB
/
result2.php
File metadata and controls
74 lines (66 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
header('Content-Type: text/html; charset=utf-8');
//phpinfo();
$link = pg_connect("host=psql-vt2013 dbname=mathlin user=mathlin password=K5YKOU4tof");
$result = pg_exec($link, "select * from bostader");
$numrows = pg_numrows($result);
$minArea = $_POST['minArea'];
$maxArea = $_POST['maxArea'];
$minRooms = $_POST['minRooms'];
$maxRooms = $_POST['maxRooms'];
$minPrice = $_POST['minPrice'];
$maxPrice = $_POST['maxPrice'];
$minFee = $_POST['minFee'];
$maxFee = $_POST['maxFee'];
$location = $_POST['location'];
$object = $_POST['object'];
$orderBy = $_POST['orderBy'];
echo "<table border='1' id='resTable' class='sortable'>
<tr>
<th style='cursor: pointer;'>Län</th>
<th style='cursor: pointer;'>Objekttyp</th>
<th style='cursor: pointer;'>Adress</th>
<th style='cursor: pointer;'>Area</th>
<th style='cursor: pointer;'>Rum</th>
<th style='cursor: pointer;'>Pris</th>
<th style='cursor: pointer;'>Avgift</th></tr>";
if($minArea != "")
$minArea = "area>='" . $minArea . "' AND ";
if($maxArea != "")
$maxArea = "area<='" . $maxArea . "' AND ";
if($minPrice != "")
$minPrice = "pris>='" . $minPrice . "' AND ";
if($maxPrice != "")
$maxPrice = "pris<='" . $maxPrice . "' AND ";
if($minFee != "")
$minFee = "avgift>='" . $minFee . "' AND ";
if($maxFee != "")
$maxFee = "avgift<='" . $maxFee . "' AND ";
if($location != "Samtliga")
$location = "lan='" . $location . "' AND ";
else
$location = "";
if($object != "Samtliga")
$object = "objekttyp='" . $object . "' AND ";
else
$object = "";
$minRooms = "rum>='" . $minRooms . "' AND ";
$maxRooms = "rum<='" . $maxRooms . "'";
$string = "SELECT * FROM bostader WHERE " . $minArea . $maxArea . $minPrice . $maxPrice . $minFee . $maxFee . $location . $object . $minRooms . $maxRooms . " ORDER BY " . $orderBy;
echo $string;
$result = pg_query($string);
$numrows = pg_numrows($result);
for($ri = 0; $ri < $numrows; $ri++) {
echo "<tr>\n";
$row = pg_fetch_array($result, $ri);
echo " <td>", $row["lan"], "</td>";
echo " <td>", $row["objekttyp"], "</td>";
echo " <td>", $row["adress"], "</td>";
echo " <td>", $row["area"], "</td>";
echo " <td>", $row["rum"], "</td>";
echo " <td>", $row["pris"], "</td>";
echo " <td>", $row["avgift"], "</td>";
}
echo "</table>";
pg_close($link);
?>