-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.php
451 lines (379 loc) · 18.2 KB
/
display.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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
<html>
<head>
<link rel="shortcut icon" href="images/title.jpg" type="image/png">
<link rel="stylesheet" href="css/zerogrid.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/responsiveslides.css">
<!-- Custom Fonts -->
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<script src="js/jquery-latest.min.js"></script>
<script src="js/script.js"></script>
<script src="js/jquery183.min.js"></script>
<script src="js/responsiveslides.min.js"></script>
<title>
Player Details
</title>
</head>
<body>
<header>
<div class="wrap-header zerogrid">
<div class="row">
<div id="cssmenu">
<ul>
<li class='active'><a href="index.php">Home</a></li>
<li><a href="squad.html">The Squad</a></li>
</ul>
</div>
<a href='index.php' class="logo"><img src="images/logo.png" /></a>
</div>
</div>
</header>
<br>
<br>
<br>
<center>
<div style="width:60%; box-shadow: 10px 10px 10px 10px; background-color:#F56614; border-radius: 20px 60px 20px 60px;">
<?php
//session_start();
$player_name=$_POST['player_name'];
//$player_name="SL Malinga";
$link=mysqli_connect('localhost','root','');
$db=mysqli_select_db($link,'ipl');
if(!$db)
{
die('unable to select database');
}
//getting image
$player_id_query="select id from players where player_name='$player_name'";
$result=mysqli_query($link,$player_id_query);
$row=mysqli_fetch_assoc($result);
$player_id=$row['id'];
$image="<img style='border-radius:30px; box-shadow:5px 5px 5px 5px;' src='player_images/$player_id.jpg' width='125' height='125'/><br>";
echo '<br><div style="width:50%;"><marquee style=" color:white; font-size:30px;"> '.$player_name.'</marquee></div><br><br>'.$image;
//getting strike rate
$strike_rate_query="select runs/balls*100 as strike_rate from (select sum(balls)as balls from ballsfaced inner join (select id
from players where player_name='$player_name')as A where player_id=id) as B, (select sum(runs) as
runs from batsman inner join (select id from players where player_name='$player_name')as C where
player_id=id)as D";
$result=mysqli_query($link,$strike_rate_query) or trigger_error('error in strike rate');
$row=mysqli_fetch_assoc($result);
$strike_rate=$row['strike_rate'];
if(!$strike_rate)
$strike_rate="NIL";
//getting economy rate
$economy_query="select runs/overs as economy from (select count(overno)as overs from bowler inner join (select id from
players where player_name='$player_name')as A where player_id=id) as D, (select runs1+runs2 as runs
from (select sum(runs) as runs1 from batsman inner join bowler inner join (select id from players where
player_name='$player_name')as B where batsman.match_id=bowler.match_id and
batsman.year=bowler.year and batsman.inning=bowler.inning and batsman.overno=bowler.overno and
bowler.player_id=id) as C , (select sum(runs) as runs2 from extras inner join bowler inner join (select id
from players where player_name='$player_name')as B where extras.match_id=bowler.match_id and
extras.year=bowler.year and extras.inning=bowler.inning and extras.overno=bowler.overno and
bowler.player_id=id) as G )as F";
$result=mysqli_query($link,$economy_query) or trigger_error('error in economy rate');
$row=mysqli_fetch_assoc($result);
$economy=$row['economy'];
if(!$economy)
$economy="NIL";
//getting wickets
$wickets_query="select count(*)as wickets from wickets inner join players inner join bowler
where players.id=bowler.player_id and bowler.overno=wickets.overno and bowler.inning=wickets.inning and
bowler.year=wickets.year and bowler.match_id=wickets.match_id and runout=0 and player_name='$player_name'";
$result=mysqli_query($link,$wickets_query) or trigger_error('error in wickets query');
$row=mysqli_fetch_assoc($result);
$wickets=$row['wickets'];
if(!$wickets)
$wickets="NIL";
//getting total runs
$total_runs_query="select sum(runs)as runs from batsman inner join players where player_name='$player_name' and
batsman.player_id=players.id and batsman.year=2015";
$result=mysqli_query($link,$total_runs_query) or trigger_error('error in total_runs query');
$row=mysqli_fetch_assoc($result);
$total_runs=$row['runs'];
if(!$total_runs)
$total_runs="NIL";
//getting runs_given
$runs_given_query="select runs1+runs2 as runs from ((select sum(runs)as runs1 from batsman inner join players
inner join bowler where player_name='$player_name' and bowler.player_id=players.id and
bowler.overno=batsman.overno and bowler.match_id=batsman.match_id and bowler.year=2015 and
bowler.inning=batsman.inning)as B, (select sum(runs)as runs2 from extras inner join players inner join
bowler where player_name='$player_name' and bowler.player_id=players.id and
bowler.overno=extras.overno and bowler.match_id=extras.match_id and bowler.year=2015 and
bowler.inning=extras.inning)as A)";
$result=mysqli_query($link,$runs_given_query) or trigger_error('error in runs_given query');
$row=mysqli_fetch_assoc($result);
$runs_given=$row['runs'];
if(!$runs_given)
$runs_given="NIL";
//getting matches_batted
$matches_batted_query="select count(*) as d from (select distinct match_id from ballsfaced inner join players where
player_name='$player_name' and ballsfaced.year=2015 and ballsfaced.player_id=players.id union select distinct match_id from wickets
inner join players where wickets.year=2015 and player_name='$player_name' and wickets.player_id=players.id )as A";
$result=mysqli_query($link,$matches_batted_query) or trigger_error('error in matches_batted query');
$row=mysqli_fetch_assoc($result);
$matches_batted=$row['d'];
if(!$matches_batted)
$matches_batted="NIL";
//getting no of sixes
$sixes_query="select count(runs) as sixes from (select runs from batsman inner join players where player_name='$player_name'
and batsman.year=2015 and batsman.player_id=players.id and batsman.runs=6) as A";
$result=mysqli_query($link,$sixes_query) or trigger_error('error in no of sixes query');
$row=mysqli_fetch_assoc($result);
$sixes=$row['sixes'];
if(!$sixes)
$sixes="NIL";
//getting no of fours
$fours_query="select count(runs) as fours from (select runs from batsman inner join players where player_name='$player_name'
and batsman.year=2015 and batsman.player_id=players.id and batsman.runs=4) as A";
$result=mysqli_query($link,$fours_query) or trigger_error('error in no of fours query');
$row=mysqli_fetch_assoc($result);
$fours=$row['fours'];
if(!$fours)
$fours="NIL";
//getting no of matches bowled
$matches_bowled_query="select count(*) as matches from ( select distinct match_id from bowler inner join players where
player_name='$player_name' and bowler.year=2015 and bowler.player_id=players.id )as A";
$result=mysqli_query($link,$matches_bowled_query) or trigger_error('error in matches_bowled query');
$row=mysqli_fetch_assoc($result);
$matches_bowled=$row['matches'];
if(!$matches_bowled)
$matches_bowled="NIL";
//getting no of 100s
$hundreds_query="select count(runs) as hundreds from (select sum(runs) as runs from batsman inner join players where
player_name='$player_name' and batsman.year=2015 and players.id=batsman.player_id group by batsman.match_id)as A where
runs>=100 and runs<200";
$result=mysqli_query($link,$hundreds_query) or trigger_error('error in hundreds query');
$row=mysqli_fetch_assoc($result);
$hundreds=$row['hundreds'];
if(!$hundreds)
$hundreds="NIL";
//getting no of 50s
$fifty_query="select count(runs) as fifty from (select sum(runs) as runs from batsman inner join players where
player_name='$player_name' and batsman.year=2015 and players.id=batsman.player_id group by batsman.match_id)as A where
runs>=50 and runs<100";
$result=mysqli_query($link,$fifty_query) or trigger_error('error in fifties query');
$row=mysqli_fetch_assoc($result);
$fifty=$row['fifty'];
if(!$fifty)
$fifty="NIL";
//getting highest_score
$highest_score_query="select max(runs)as runs from (select sum(runs)as runs,match_id from batsman inner join
players where player_name='$player_name' and batsman.year=2015 and players.id=batsman.player_id group by match_id)as A";
$result=mysqli_query($link,$highest_score_query) or trigger_error('error in highest_score query');
$row=mysqli_fetch_assoc($result);
$highest_score=$row['runs'];
if(!$highest_score)
$highest_score="NIL";
//getting ballsfaced
$ballsfaced_query="select sum(balls) as balls from ballsfaced inner join players where player_name='$player_name' and
ballsfaced.year=2015 and ballsfaced.player_id=players.id";
$result=mysqli_query($link,$ballsfaced_query) or trigger_error('error in ballsfaced query');
$row=mysqli_fetch_assoc($result);
$ballsfaced=$row['balls'];
if(!$ballsfaced)
$ballsfaced="NIL";
//getting no_of _maidens
$maidens_query="select x-y as maidens from (select count(*) as x from
players inner join bowler where player_name='$player_name' and bowler.player_id=players.id and bowler.year=2015)as A,
(select count(*)as y from (select batsman.overno,batsman.match_id,batsman.inning from
players inner join bowler inner join batsman
where player_name='$player_name' and bowler.player_id=players.id and batsman.match_id=bowler.match_id and
batsman.inning=bowler.inning and batsman.year=bowler.year and batsman.year=2015 and batsman.overno=bowler.overno
group by batsman.match_id,batsman.inning,batsman.year,batsman.overno )as B )as C";
$result=mysqli_query($link,$maidens_query) or trigger_error('error in maidens query');
$row=mysqli_fetch_assoc($result);
$maidens=$row['maidens'];
if(!$maidens)
$maidens="NIL";
//getting no_of _3_wickets
$wickets_3_query="select player_name,player_id,count(d) as three from (select player_name,b.player_id
,b.match_id,b.year,b.inning,count(w.ballno) as d from wickets w inner join players p inner join bowler b
where p.id=b.player_id and b.year=2015 and b.match_id=w.match_id and b.year=w.year and
b.inning=w.inning and b.overno=w.overno group by
b.player_id,b.match_id,b.year,b.inning,player_name)as A where d=3 and player_name='$player_name' group by player_id order by three
desc";
$result=mysqli_query($link,$wickets_3_query);
if($result)
{
$row=mysqli_fetch_assoc($result);
$threes=$row['three'];
}
else
$threes=0;
if(!$threes)
$threes="NIL";
//getting no_of _4_wickets
$wickets_4_query="select player_name,player_id,count(d) as fours from (select player_name,b.player_id
,b.match_id,b.year,b.inning,count(w.ballno) as d from wickets w inner join players p inner join bowler b
where p.id=b.player_id and b.year=2015 and b.match_id=w.match_id and b.year=w.year and
b.inning=w.inning and b.overno=w.overno group by
b.player_id,b.match_id,b.year,b.inning,player_name)as A where d=4 and player_name='$player_name' group by player_id order by fours
desc";
$result=mysqli_query($link,$wickets_4_query);
if($result)
{
$row=mysqli_fetch_assoc($result);
$fours=$row['fours'];
}
else
$fours=0;
if(!$fours)
$fours="NIL";
//getting no_of _overs
$overs_query="select count(overno) as overs from bowler,players where player_name='$player_name' and player_id=id group by player_id";
$result=mysqli_query($link,$overs_query);
if($result)
{
$row=mysqli_fetch_assoc($result);
$overs=$row['overs'];
}
else
$overs=0;
if(!$overs)
$overs="NIL";
//getting bowlers_best
$bowler_best_query="select W.player_name,W.match_id,W.inning,W.wickets,R.runs from
(select player_name,b.match_id,b.inning,count(ballno)as wickets from bowler b,players p,wickets w where b.player_id=p.id and
b.match_id=w.match_id and b.year=w.year and b.inning=w.inning and b.overno=w.overno and b.year=2015 and w.runout=0 and p.player_name='$player_name' group by player_name,match_id,inning)as W,
(select X.player_name,X.match_id,X.inning,(runs1+runs2)as runs from
(select player_name,b.match_id,b.inning,sum(runs)as runs1 from bowler b,players p,batsman bat where b.player_id=p.id and b.match_id=bat.match_id and b.year=bat.year and b.inning=bat.inning and b.overno=bat.overno and b.year=2015 group by player_name,match_id,inning)as X,
(select player_name,b.match_id,b.inning,sum(runs)as runs2 from bowler b,players p,extras bat where b.player_id=p.id and b.match_id=bat.match_id and b.year=bat.year and b.inning=bat.inning and b.overno=bat.overno and b.year=2015 group by player_name,match_id,inning)as Y
where X.player_name=Y.player_name and X.match_id=Y.match_id and X.inning=Y.inning and X.player_name='$player_name')as R
where W.player_name=R.player_name and W.match_id=R.match_id and W.inning=R.inning
order by wickets desc,runs asc limit 0,1";
$result=mysqli_query($link,$bowler_best_query)or trigger_error('error in bowler best query');
if($result)
{
$row=mysqli_fetch_assoc($result);
$best_wickets=$row['wickets'];
$best_runs=$row['runs'];
}
else {
$best_wickets=0;
$best_runs=0;
}
if(!($best_runs || $best_wickets))
{
$best_wickets="NIL";
$best_runs="NIL";
}
//<th colspan=3 style='float:right; color:white; font-size:20px; align:center; margin-bottom:30px;'></th>
echo "<br><table>
<tr style='margin-bottom:20px;'>
<th colspan=3 style='font-family:tahoma; color:white; font-size:20px; align:center;'>NAME :".$player_name."
</th>
</tr>
<tr>
<th colspan=2 style='font-family:Comic Sans MS; background-color:white; font-size:20px; align:center;'>BATTING STATS
</th>
<th colspan=2 style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px; align:center;'>BOWLING STATS
</th>
";
echo "
<tr>
<th style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>MATCHES
</th>
<td style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>".$matches_batted."
</td>
<th style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> MATCHES </th>
<td style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ".$matches_bowled."</td>
</tr>
<tr>
<th style='font-family:Comic Sans MS; background-color:white; font-size:20px;'> STRIKE RATE </th>
<td style='font-family:Comic Sans MS; align:center; background-color:white; font-size:20px;'>".$strike_rate."</td>
<th style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ECONOMY RATE </th>
<td style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ".$economy."</td>
</tr>
<tr>
<th style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>TOTAL RUNS
</th>
<td style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>".$total_runs."
</td>
<th style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> WICKETS </th>
<td style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ".$wickets."</td>
</tr>
<tr>
<th style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>100S
</th>
<td style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>".$hundreds."
</td>
<th style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> BBM </th>
<td style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ".$best_wickets."/".$best_runs."</td>
</tr>
<tr>
<th style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>HIGHEST SCORE
</th>
<td style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>".$highest_score."
</td>
<th style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> MAIDENS </th>
<td style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ".$maidens."</td>
</tr>
<tr>
<th style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>50s
</th>
<td style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>".$fifty."
</td>
<th style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> OVERS </th>
<td style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ".$overs."</td>
</tr>
<tr>
<th style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>6s
</th>
<td style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>".$sixes."
</td>
<th style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> 3w </th>
<td style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ".$threes."</td>
</tr>
<tr>
<th style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>4s
</th>
<td style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>".$fours."
</td>
<th style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> 4w </th>
<td style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ".$fours."</td>
</tr>
<tr>
<th style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>BALLS FACED
</th>
<td style='font-family:Comic Sans MS; background-color:white; font-size:20px;'>".$ballsfaced."
</td>
<th style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> RUNS GIVEN </th>
<td style='font-family:Comic Sans MS; background-color:#E1D7D1; font-size:20px;'> ".$runs_given."</td>
</tr>
</table>
<br><br>
";
mysqli_close($link);
?>
</center>
<footer>
<div class="wrap-footer">
<div class="zerogrid">
<div class="row">
<h3>Contact</h3>
<span>Phone / +80 999 99 9999 </span></br>
<span>Email / info@domain.com </span></br>
<span>Studio / Moonshine St. 14/05 Light City </span></br>
<span><strong>Copyright 20xx - <a href="http://www.zerotheme.com" rel="nofollow" target="_blank">Html5 Templates</a> Designed by <a href="http://www.zerotheme.com" rel="nofollow" target="_blank">ZEROTHEME</a></strong></span>
</div>
</div>
</div>
</footer>
</body>
</html>