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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
|
<?php // ============================================================ // BETSY – BETting SYstem | scores.php // Hit-Matrix: alle User × alle Tips, mit Einzelscores und // Gesamtscore pro User, gefiltert nach Jahr. // DB-Tabellen: // users : u_id, u_name // betsy : b_id, b_bet // betsyresults : br_b_id, br_result (Ergebnisse) // betsytips : bt_u_id, bt_b_id, bt_tip (User-Tipps) // betsyscores : bs_u_id, bs_b_id, bs_scores, bs_year // ============================================================
require '../dbconnect.php';
function esc($s) { return htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); }
function db_query($sql) { $res = mysql_query($sql); if (!$res) die("DB-Fehler: " . mysql_error() . "<br>SQL: $sql"); return $res; }
dbconnect();
// ── Verfügbare Jahre aus betsyscores ────────────────────── $years_list = array(); $res = db_query("SELECT DISTINCT bs_year FROM betsyscores ORDER BY bs_year DESC"); while ($row = mysql_fetch_assoc($res)) { $years_list[] = (int)$row['bs_year']; }
// Wenn keine Einträge vorhanden, aktuelles Jahr verwenden if (empty($years_list)) { $years_list[] = (int)date('Y'); }
// Gewähltes Jahr (GET-Parameter oder neuestes Jahr) $sel_year = isset($_GET['year']) ? (int)$_GET['year'] : $years_list[0];
// ── Alle Tip-Kategorien ──────────────────────────────────── $betsy = array(); $res = db_query("SELECT b_id, b_bet FROM betsy ORDER BY b_id ASC"); while ($row = mysql_fetch_assoc($res)) { $betsy[(int)$row['b_id']] = $row['b_bet']; } $bid_list = array_keys($betsy);
// ── Alle User — nur jene mit Tipps in betsytips ─────────── $users = array(); $res = db_query( "SELECT u.u_id, u.u_name FROM users u WHERE u.u_id IN (SELECT DISTINCT bt_u_id FROM betsytips) ORDER BY u.u_name ASC" ); while ($row = mysql_fetch_assoc($res)) { $users[(int)$row['u_id']] = $row['u_name']; }
// ── Welche Ergebnisse sind bereits eingetragen? ──────────── // b_id => true/false $results_entered = array(); $res = db_query("SELECT br_b_id FROM betsyresults"); while ($row = mysql_fetch_assoc($res)) { $results_entered[(int)$row['br_b_id']] = true; }
// ── Scores aus betsyscores für gewähltes Jahr ────────────── // $scores[u_id][b_id] = bs_scores $scores = array(); $res = db_query("SELECT bs_u_id, bs_b_id, bs_scores FROM betsyscores WHERE bs_year=$sel_year"); while ($row = mysql_fetch_assoc($res)) { $uid = (int)$row['bs_u_id']; $bid = (int)$row['bs_b_id']; if (!isset($scores[$uid])) { $scores[$uid] = array(); } $scores[$uid][$bid] = (int)$row['bs_scores']; }
// ── Gesamtscores + Anzahl korrekter Tipps pro User ──────── $totals = array(); $correct_counts = array(); // u_id => Anzahl Tipps mit bs_scores > 0 foreach ($users as $uid => $uname) { $total = 0; $correct = 0; if (isset($scores[$uid])) { foreach ($scores[$uid] as $bid => $s) { $total += $s; if ($s > 0) $correct++; } } $totals[$uid] = $total; $correct_counts[$uid] = $correct; }
// User nach Gesamtscore sortieren (absteigend) arsort($totals); $sorted_uids = array_keys($totals);
// ── Max-Score für Balken-Normierung ─────────────────────── $max_total = !empty($totals) ? max($totals) : 1; if ($max_total == 0) $max_total = 1; ?> <!DOCTYPE html> <html> <head> <title>BETSY – Scores</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="viewport" content="width=device-width, initial-scale=0.7">
<!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//mamnaslim.dsmynas.net/piwik/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Piwik Code -->
<style type="text/css"> #menu__toggle { opacity: 0; } #menu__toggle:checked + .menu__btn > span { transform: rotate(45deg); } #menu__toggle:checked + .menu__btn > span::before { top: 0; transform: rotate(0deg); } #menu__toggle:checked + .menu__btn > span::after { top: 0; transform: rotate(90deg); } #menu__toggle:checked ~ .menu__box { left: 0 !important; } .menu__btn { position: fixed; top: 20px; left: 20px; width: 26px; height: 26px; cursor: pointer; z-index: 200; } .menu__btn > span, .menu__btn > span::before, .menu__btn > span::after { display: block; position: absolute; width: 100%; height: 2px; background-color: #616161; transition-duration: .25s; } .menu__btn > span::before { content: ''; top: -8px; } .menu__btn > span::after { content: ''; top: 8px; } .menu__box { display: block; position: fixed; top: 0; left: -100%; width: 300px; height: 100%; margin: 0; padding: 40px 0; list-style: none; background-color: #ECEFF1; box-shadow: 2px 2px 6px rgba(0,0,0,.4); transition-duration: .25s; overflow: auto; z-index: 199; } .menu__item { display: block; padding: 12px 24px; color: #333; font-family: Arial, sans-serif; font-size: 18px; font-weight: 400; text-decoration: none; transition-duration: .25s; } .menu__item:hover { background-color: #CFD8DC; text-decoration: none; } .menu__home { position: fixed; top: 7px; right: 17px; } </style>
<style> *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, Helvetica, Sans-Serif; color: #222; background: #fff; }
/* ── Page wrapper ─────────────────────────── */ .page-wrap { max-width: 98%; margin: 42px auto 60px; padding: 0 20px; }
/* ── Header ───────────────────────────────── */ .page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 32px; font-weight: bold; }
/* ── Year selector ────────────────────────── */ .year-form { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.year-form label { font-weight: bold; color: #444; }
.year-form select { font-family: Arial, Helvetica, sans-serif; font-size: 16px; padding: 5px 10px; border: 1px solid #b0c4d8; border-radius: 4px; background: #fff; cursor: pointer; }
.year-form button { font-family: Arial, Helvetica, sans-serif; font-size: 14px; padding: 6px 14px; background: #2e8def; color: #fff; border: none; border-radius: 4px; cursor: pointer; } .year-form button:hover { background: #1a73d4; }
/* ── Legend ───────────────────────────────── */ .legend { display: flex; gap: 20px; margin-bottom: 20px; font-size: 14px; color: #555; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 22px; height: 22px; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; }
.dot-correct { background: #2e8def; color: #fff; } .dot-wrong { background: #f0f0f0; color: #999; border: 1px solid #ddd; } .dot-pending { background: #fff; color: #ccc; border: 1px dashed #ccc; }
/* ── Sticky top section ───────────────────── */ .sticky-top { position: sticky; top: 0; z-index: 30; background: #fff; padding-bottom: 8px; }
/* ── Matrix table wrapper ─────────────────── */ /* height set by JS = viewport minus .sticky-top height */ .matrix-scroll { overflow-x: auto; overflow-y: auto; /* height applied via JS */ }
/* ── Matrix table ─────────────────────────── */ .matrix { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; white-space: nowrap; }
/* Sticky th — sticky within .matrix-scroll, top: 0 */ .matrix thead th { position: sticky; top: 0; z-index: 20; padding: 4px 3px; text-align: center; font-weight: bold; font-size: 12px; color: #555; border-bottom: 2px solid #ccc; min-width: 38px; background: #fff; }
.matrix thead th.col-name { text-align: left; padding: 4px 14px 4px 4px; min-width: 120px; font-size: 14px; color: #222; background: #fff; }
.matrix thead th.col-total { min-width: 80px; color: #222; font-size: 14px; border-left: 2px solid #ccc; background: #fff; }
/* Sticky left: rank column (col 1) */ .matrix thead th.col-rank-head, .matrix tbody td.col-rank, .matrix .summary-row td.col-rank { position: sticky; left: 0; z-index: 10; background: #fff; }
/* Corner cell: rank header — above both sticky row and sticky col */ .matrix thead th.col-rank-head { z-index: 25; }
/* Sticky left: name column (col 2) — offset by rank column width (32px) */ .matrix thead th.col-name, .matrix tbody td.col-name, .matrix .summary-row td.col-name { position: sticky; left: 32px; z-index: 10; background: #fff; border-right: 1px solid #ddd; padding-right: 10px; }
/* Corner cell: name header — above both sticky row and sticky col */ .matrix thead th.col-name { z-index: 25; }
/* Keep sticky cells visible on row hover */ .matrix tbody tr:hover td.col-rank, .matrix tbody tr:hover td.col-name { background: #f5f9ff; }
.matrix .summary-row td.col-rank, .matrix .summary-row td.col-name { background: #fafafa; }
/* Tip header: number + short label on hover */ .tip-head { cursor: default; position: relative; }
.tip-head:hover .tip-tooltip { display: block; }
.tip-tooltip { display: none; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); background: #333; color: #fff; font-size: 11px; padding: 4px 8px; border-radius: 4px; white-space: nowrap; z-index: 100; font-weight: normal; pointer-events: none; }
/* Rows */ .matrix tbody tr { border-bottom: 1px solid #eee; transition: background .1s; }
.matrix tbody tr:hover { background: #f5f9ff; }
.matrix tbody tr:hover td { background: transparent; }
/* Rank column */ .matrix tbody td.col-rank { text-align: center; font-size: 14px; font-weight: bold; color: #999; padding: 6px 6px; width: 32px; }
td.rank-1 { color: #f9a825; font-size: 18px; } td.rank-2 { color: #9e9e9e; font-size: 16px; } td.rank-3 { color: #e64a19; font-size: 15px; }
/* Name column */ .matrix tbody td.col-name { font-weight: bold; font-size: 16px; padding: 6px 14px 6px 4px; color: #222; }
/* Score cells */ .matrix tbody td.col-cell { text-align: center; padding: 3px 2px; vertical-align: middle; }
.cell-inner { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 3px; font-size: 11px; line-height: 1.2; }
.cell-correct { background: #2e8def; color: #fff; }
.cell-wrong { background: #f0f0f0; color: #999; border: 1px solid #e0e0e0; }
.cell-pending { background: #fff; color: #ccc; border: 1px dashed #ddd; }
.cell-notipped { background: #fafafa; color: #ddd; border: 1px solid #f0f0f0; }
.cell-symbol { font-size: 12px; font-weight: bold; line-height: 1; }
.cell-score { font-size: 10px; line-height: 1; margin-top: 1px; }
/* Total column */ .matrix tbody td.col-total { text-align: right; padding: 6px 12px; border-left: 2px solid #ccc; vertical-align: middle; }
.total-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.total-score { font-size: 17px; font-weight: bold; color: #222; }
.total-correct { font-size: 17px; font-weight: bold; color: #222; margin-left: 3px; }
.total-bar-track { width: 60px; height: 5px; background: #e0e0e0; border-radius: 3px; overflow: hidden; }
.total-bar-fill { height: 100%; background: linear-gradient(90deg, #2e8def, #5cb8ff); border-radius: 3px; }
/* Tip count summary row */ .summary-row td { border-top: 2px solid #ccc; padding: 5px 3px; text-align: center; font-size: 11px; color: #888; background: #fafafa; }
.summary-row td.col-name { text-align: left; font-weight: bold; font-size: 13px; color: #555; padding-left: 4px; }
.summary-row td.col-total { text-align: right; padding-right: 12px; font-size: 13px; font-weight: bold; color: #555; }
/* ── No data message ──────────────────────── */ .no-data { text-align: center; padding: 60px 20px; color: #999; font-size: 18px; }
/* ── Footer ───────────────────────────────── */ footer { text-align: center; padding: 20px; font-size: 16px; color: #aaa; margin-top: 20px; } </style>
</head> <body bgcolor="#FFFFFF" text="#000000" link='#000000' alink='#000000' vlink='#000000'>
<link href="../shoutbox/style.css" rel="stylesheet" type="text/css" />
<div class="hamburger-menu"> <input id="menu__toggle" type="checkbox" /> <label class="menu__btn" for="menu__toggle"> <span></span> </label> <ul class="menu__box"> <li><h1> BETSY</h1></li> <li><a class="menu__item" href="scores.php" target="mainFrame">Scores</a></li> <li><a class="menu__item" href="tipsresults.php" target="mainFrame">Results</a></li> <li><a class="menu__item" href="results.php" target="mainFrame">Enter Results</a></li> <li><a class="menu__item" href="admin/admin.html" target="mainFrame">Admin</a></li> </ul> <div class="menu__home"> <a href="betsy.php" target="mainFrame"><img src="../images/home.png" width="32" height="28"></a> </div> </div>
<div class="page-wrap">
<!-- Sticky top: header + year form + legend --> <div class="sticky-top"> <div class="page-header"> <div class="page-title">BETSY Scores <?php echo $sel_year; ?></div> <form class="year-form" method="GET" action=""> <label for="year">Season:</label> <select name="year" id="year"> <?php foreach ($years_list as $yr): ?> <option value="<?php echo $yr; ?>" <?php echo ($yr === $sel_year) ? 'selected' : ''; ?>> <?php echo $yr; ?> </option> <?php endforeach; ?> </select> <button type="submit">Show</button> </form> </div>
<!-- Legend --> <div class="legend"> <div class="legend-item"> <div class="legend-dot dot-correct">✓</div> <span>Correct tip</span> </div> <div class="legend-item"> <div class="legend-dot dot-wrong">✗</div> <span>Wrong tip</span> </div> <div class="legend-item"> <div class="legend-dot dot-pending">·</div> <span>Result pending</span> </div> <div class="legend-item"> <div class="legend-dot" style="background:#fafafa;border:1px solid #f0f0f0;color:#ddd;">–</div> <span>No tip placed</span> </div> <div class="legend-item"> <span style="font-size:14px;font-weight:bold;color:#222;">(n)</span> <span>Number of correct tips</span> </div> </div> </div><!-- /.sticky-top -->
<?php if (empty($users) || empty($betsy)): ?> <div class="no-data">No data available for <?php echo $sel_year; ?>.</div> <?php else: ?>
<!-- Matrix --> <div class="matrix-scroll"> <table class="matrix"> <thead> <tr> <th class="col-rank-head" style="width:32px"></th> <th class="col-name">User</th> <?php foreach ($bid_list as $bid): ?> <th class="tip-head"> <?php echo $bid; ?> <div class="tip-tooltip"><?php echo esc($betsy[$bid]); ?></div> </th> <?php endforeach; ?> <th class="col-total">Total Score</th> </tr> </thead> <tbody> <?php // Collect column totals (how many correct per tip) $col_correct = array(); foreach ($bid_list as $bid) { $col_correct[$bid] = 0; }
$rank = 0; $prev_total = -1; $display_rank = 0;
foreach ($sorted_uids as $uid): if (!isset($users[$uid])) continue; $uname = $users[$uid]; $user_total = $totals[$uid];
// Calculate rank (tied users get same rank) $display_rank++; if ($user_total !== $prev_total) { $rank = $display_rank; $prev_total = $user_total; }
// Rank label if ($rank == 1) { $rank_label = '🥇'; $rank_class = 'rank-1'; } elseif ($rank == 2) { $rank_label = '🥈'; $rank_class = 'rank-2'; } elseif ($rank == 3) { $rank_label = '🥉'; $rank_class = 'rank-3'; } else { $rank_label = $rank; $rank_class = ''; }
$bar_pct = $max_total > 0 ? round($user_total / $max_total * 100) : 0; ?> <tr> <td class="col-rank <?php echo $rank_class; ?>"><?php echo $rank_label; ?></td> <td class="col-name"><?php echo esc($uname); ?></td>
<?php foreach ($bid_list as $bid): $has_result = isset($results_entered[$bid]); $has_score = isset($scores[$uid][$bid]); $cell_score = $has_score ? $scores[$uid][$bid] : 0;
if (!$has_result): // Result not yet entered → pending $cell_class = 'cell-pending'; $symbol = '·'; $score_disp = ''; elseif ($has_score && $cell_score > 0): // Correct $cell_class = 'cell-correct'; $symbol = '✓'; $score_disp = $cell_score; $col_correct[$bid]++; elseif ($has_score): // Scored but 0 points → wrong $cell_class = 'cell-wrong'; $symbol = '✗'; $score_disp = '0'; else: // Result entered but no score entry → no tip placed $cell_class = 'cell-notipped'; $symbol = '–'; $score_disp = ''; endif; ?> <td class="col-cell"> <div class="cell-inner <?php echo $cell_class; ?>"> <span class="cell-symbol"><?php echo $symbol; ?></span> <?php if ($score_disp !== ''): ?> <span class="cell-score"><?php echo $score_disp; ?></span> <?php endif; ?> </div> </td> <?php endforeach; ?>
<td class="col-total"> <div class="total-wrap"> <span class="total-score"> <?php echo $user_total; ?> <span class="total-correct">(<?php echo $correct_counts[$uid]; ?>)</span> </span> <div class="total-bar-track"> <div class="total-bar-fill" style="width:<?php echo $bar_pct; ?>%"></div> </div> </div> </td> </tr> <?php endforeach; ?>
<!-- Summary row: correct count per tip --> <tr class="summary-row"> <td class="col-rank"></td> <td class="col-name">Correct tips</td> <?php $grand_total_correct = 0; foreach ($bid_list as $bid): $grand_total_correct += $col_correct[$bid]; ?> <td><?php echo $col_correct[$bid] > 0 ? $col_correct[$bid] : ''; ?></td> <?php endforeach; ?> <td class="col-total"><?php echo $grand_total_correct; ?></td> </tr>
</tbody> </table> </div>
<?php endif; ?>
</div>
<footer> © 2027 - GRID TIP </footer>
<script> window.onload = function() { var stickyTop = document.querySelector('.sticky-top'); var matrixScroll = document.querySelector('.matrix-scroll'); if (!stickyTop || !matrixScroll) return;
function setScrollHeight() { var topH = stickyTop.offsetHeight; matrixScroll.style.height = (window.innerHeight - topH - 40) + 'px'; }
setScrollHeight(); window.addEventListener('resize', setScrollHeight); }; </script>
</body> </html>
|