-
Notifications
You must be signed in to change notification settings - Fork 1
/
cardd.php
319 lines (259 loc) · 7.14 KB
/
cardd.php
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<!DOCTYPE html>
<html>
<head>
<title>
Page
</title>
<link rel="stylesheet" type="text/css" href="cardd.css">
<link rel="stylesheet" type="text/css" href="nav.css">
<link rel="stylesheet" type="text/css" href="edpwof.css">
<style>
.ind
{
position: fixed;
/*top:245px;*/
bottom: 25px;
right:20px;
background-color: white;
width:300px;
box-shadow: 4px 4px 5px;
}
</style>
</head>
<body background="pwofb.jpg">
<header style="padding: 4px 0;opacity:0.7;"><center><h1>ROOM SHARE</h1></center></header>
<div class="topnav" id="myTopnav">
<a href="card.html">Home</a>
<a href="likepwof.php">Liked</a>
<a href="refer.html">Referals</a>
<a href="pwofed.php">Edit</a>
<a href="match.php">Matched Profiles</a>
<a href="logout.php" style="float: right;">Logout</a>
</div>
<div class="ind">
<center><h3>Index</h3>
<div style="background-color: #E8A726;">Critical percentage</div>
<div style="background-color: #1A97C4;;">Non-Critical percentage</div>
</center>
</div>
<?php
$flag=0;
$con=mysqli_connect('127.0.0.1','root','123456');
if(!$con)
{
echo 'Connection error';
}
if(!mysqli_select_db($con,'project'))
{
echo 'Database not selected';
}
session_start();
//$val=50;
$vemail=$_SESSION['lemail'];
$sql="SELECT * FROM pwf";
$result=mysqli_query($con,$sql);
$result1=mysqli_query($con,$sql);
$arr_fn=array("smoking","drinking","travel","occupation","eat","foodarr","sleep","parties","caste","visitors");
$arr_dr=array($_POST['dsmoking'],$_POST['ddrinking'],$_POST['dtravel'],$_POST['doccu'],$_POST['deat'],$_POST['deata'],$_POST['dsleeph'],$_POST['dparty'],$_POST['dcaste'],$_POST['dvisit']);
$gender=$_POST['dsex'];
$area=$_POST['darea'];
$j=0;
$num=0;
$arp=array(array());
if(mysqli_num_rows($result) > 0)
while($row=mysqli_fetch_assoc($result))
{
$ctotal=0;
$nctotal=0;
$mctotal=0;
$mnctotal=0;
$rop=$row['pwfid'];
$arp[$j][0]=$row['pwfid'];
$rm="SELECT * FROM roommate WHERE rpwfid='$rop'";
$rq=mysqli_query($con,$rm);
for($i=0;$i<10;$i++)
{
if(isset($_POST[$arr_fn[$i]]))
{
$ctotal++;
if($arr_dr[$i]==$row[$arr_fn[$i]])
$mctotal++;
}
else
{
$nctotal++;
if($arr_dr[$i]==$row[$arr_fn[$i]])
$mnctotal++;
}
}
while($row1=mysqli_fetch_assoc($rq))
{
for($i=0;$i<10;$i++)
{
if(isset($_POST[$arr_fn[$i]]))
{
$ctotal++;
if($arr_dr[$i]==$row1[$arr_fn[$i]])
$mctotal++;
}
else
{
$nctotal++;
if($arr_dr[$i]==$row1[$arr_fn[$i]])
$mnctotal++;
}
}
}
if($ctotal==0)
{
$cper=0;
}
else
{
$val1=$mctotal/$ctotal;
$cper=$val1*100;
}
$val1=$mnctotal/$nctotal;
$ncper=$val1*100;
$arp[$j][1]=$cper;
$arp[$j][2]=$ncper;
$j=$j+1;
$num=$num+1;
// echo $row['pwfid'];
/* echo $ctotal . "<br>";
echo $nctotal."<br>";
echo $mctotal."<br>";
echo $mnctotal."<br><br><br>";
echo "Percentage <br>";
echo $val."<br>";*/
//$val=1;
}
$arp[$j][0]=-1;
$arp[$j][1]=-1;
$arp[$j][2]=-1;
for($i=0;$i<$num;$i++)
{
for($j=0;$j<$num-1;$j++)
{
if($arp[$j][1] < $arp[$j+1][1])
{
$temp0=$arp[$j][0];
$temp1=$arp[$j][1];
$temp2=$arp[$j][2];
$arp[$j][0]=$arp[$j+1][0];
$arp[$j][1]=$arp[$j+1][1];
$arp[$j][2]=$arp[$j+1][2];
$arp[$j+1][0]=$temp0;
$arp[$j+1][1]=$temp1;
$arp[$j+1][2]=$temp2;
}
}
}
/*
$i=0;
while($arp[$i][0]!=-1)
{
echo $arp[$i][0]." ".$arp[$i][1]." ".$arp[$i][2]." ";
echo "<br>";
$i=$i+1;
}*/
$j=0;
while($arp[$j][0]!=-1)
{
// echo $arp[$j][0]." ".$arp[$j][1]." ".$arp[$j][2]." ";
// echo "<br>";
$cardid=$arp[$j][0];
$rc="SELECT count(*) FROM roommate WHERE rpwfid='$cardid'";
$row1=mysqli_query($con,$rc);
$row2=mysqli_fetch_assoc($row1);
$roommatecount=$row2['count(*)'];
$roommatecount=$roommatecount+2;
$budget=$_POST['dbudget'];
$sql="SELECT * FROM pwf p JOIN flat f ON pwfflatid=fid AND rent/'$roommatecount' < '$budget' AND pwfid='$cardid'";
$result1=mysqli_query($con,$sql);
$row=mysqli_fetch_assoc($result1);
$displaybud="SELECT rent from flat where fid=(SELECT pwfflatid FROM pwf where pwfid='$cardid')";
$result=mysqli_query($con,$displaybud);
$rent1=mysqli_fetch_assoc($result);
$rent=$rent1['rent'];
$genderfunc=mysqli_query($con,"SELECT fullcheck('$gender','$cardid','$area') as gcheck");
$genderrow=mysqli_fetch_assoc($genderfunc);
$genderfinal=$genderrow['gcheck'];
//echo $genderrow['gcheck'];
if($rent/$roommatecount < $_POST['dbudget'] && $genderfinal)
{
$flag=1;
?>
<form action="rf.php" method="post" target="_blank">
<div class="card" style="box-shadow: 0 12px 15px 0 rgba(1,1,1,0.8);background-color: #fff; transition: 0.3s; width:50%; margin: 5% 25% 0% 25%;">
<div id="pro">
<div id="bar" onmouseover="fill(this,<?php echo $arp[$j][1] ?>)" style="text-align: center; padding-top: 5px;background-color: #E8A726">
</div>
</div>
<div class="info">
<img id="im" src="flatuploads/<?php if($row['image1'])
echo $row['image1'];
else
echo "default.png"; ?>">
<img id="im" src="flatuploads/<?php if($row['image2'])
echo $row['image2'];
else
echo "default.png"; ?>"><br>
Rent:<?php echo round($rent/$roommatecount); ?><br>
Current occupants:<?php echo $roommatecount-1; ?><br>
Critical percentage:<?php echo ceil($arp[$j][1]); ?><br>
Non-Critical percentage:<?php echo ceil($arp[$j][2]); ?>
</div>
<div id="an">
<button type="submit" name="vmbtn" value=<?php echo $row['pwfid'] ?> style="border: none;background-color: #006600;color: white;padding: 14px 20px;cursor: pointer ;margin:3.5% 2% 10% 5%;" >View More</button>
</div>
<div id="pro">
<div id="bar" onmouseover="fill(this,<?php echo $arp[$j][2] ?>)" style="text-align: center; padding-top: 5px;background-color: #1A97C4;">
</div>
</div>
</div>
</form>
<?php
} $j=$j+1; /*echo "<br><br>"*/ ?>
<?php
}
if($flag==0)
{
echo "<script>alert('No cards to display...Select another option');</script>";
header("refresh:0;url=card.html");
}
?>
<?php mysqli_close($con);
?>
<script type="text/javascript">
function fill(x,m)
{
//var elem=document.getElementById("bar");
//window.alert("Inside function");
var width=0;
var id=setInterval(frame,1);
if(m==0)
{
m=0.1;
}
function frame()
{
//window.alert("Inside function");
if(width>=m)
clearInterval(id);
else
{
//window.alert("Inside function");
width++;
x.style.width = width + '%';
x.innerHTML = width * 1 + '%';
}
if(m==0.1)
{
x.innerHTML = 0;
}
}
}
</script>
</body>
</html>