-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproperty.php
More file actions
82 lines (65 loc) · 2.84 KB
/
property.php
File metadata and controls
82 lines (65 loc) · 2.84 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
75
76
77
78
79
80
81
82
<!DOCTYPE HTML>
<html>
<head>
<title> Using property details </title>
</head>
<body bgcolor="white">
<h1> Search propertys : </h1>
<?php
$formtop='<form <action="<?php echo htmlentities($_SERVER[$redir]); ?>" method="post">';
$menu=$formtop.'<select name="second" style="display: none"> <option value=""></option></select>';
$subbutton='<input type="submit" name="formSubmit" value="Submit" /></form><a href="index.html"> Back to index </a>';
$formdetail="";
$query="";
$wherecond="";
$result_id="";
$counter=0;
$values= array ('City', 'Rooms', 'Type');
if(isset($_POST['formSubmit'])) {$query= $_POST['first'];
$wherecond= $_POST['second'];}
$conn_id = @mysql_connect ("server", "id","password")
or exit ();
mysql_select_db ("Dreamhome_km32", $conn_id);
if (!$query && !$wherecond){
$formdetail.=$menu.'
<label for="first">Please choose how you like to search :</label><br>
<select name="first">
<option value="">Select an option...</option>';
while ($counter<count($values)){
$formdetail.='<option value="'.$values[$counter].'">'.$values[$counter].'</option>';
$counter++;}
$formdetail.='
</select>
<br>'.$subbutton;
}
if ($query && !$wherecond){
printf("<h1>Showing all properties : Please select from menu.</h1>");
$result_id = mysql_query ("select * from property_for_rent group by ".$query) or exit ();
if ($result_id){
while ($row = mysql_fetch_array ($result_id)){
printf ("<p> ".$row["Street"]." ".$row["Area"]." " .$row[$query]." ".$row["Type"]." ".$row["Rent"]." " ); }
$menu=$formtop.'<select name="first" style="display: none">
<option value='.$query.'></option>
</select>';
$result_id = mysql_query ("select Street, Area, Type, Rent," .$query. " from property_for_rent group by ".$query) or exit ();
$menu.="<label for='second'> Search parameters : </label> <select name='second'><option value=''>Select an option...</option>";
while ($row = mysql_fetch_array ($result_id)){
$menu.="<option value=".$row[$query].">".$row[$query]."</option>";
}
$menu.=$subbutton;
mysql_free_result ($result_id);
}
}
elseif ($query && $wherecond){
if ($query==="City"){ printf ("<h1>Showing all properties in :".$wherecond)."</h1>";}
if ($query==="Rooms"){ printf ("<h1>Showing all properties with :".$wherecond." rooms </h1>");}
if ($query==="Type"){ printf ("<h1>Showing all properties that are a :".$wherecond)."</h1>";}
$result_id = mysql_query ("select * from property_for_rent where ".$query." = '".$wherecond."'") or exit ();
while ($row = mysql_fetch_array ($result_id)){
printf ("<p> ".$row["Street"]." ".$row["Area"]." " .$row[$query]." <p>Property Type: ".$row["Type"]." </p><p>Rent : $".$row["Rent"]." " ); }
mysql_free_result ($result_id);}
?>
<span><?php printf( $formdetail); ?> </span>
<span><?php printf( $menu); ?> </span>
</body>
</html>