| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/thelittlebigshow/app/admin/ |
Upload File : |
<?php
session_start();
require_once 'config/config.php';
require_once BASE_PATH . '/includes/auth_validate.php';
include_once("../db.php");
$currentYear = date('Y');
$categoryResults = [];
$categorySql = "
SELECT
vehicles.name,
vehicles.vehicle_maker,
vehicles.vehicle_model,
vehicles.vehicle_year,
vehicles.category,
COUNT(vote.id) AS score_count,
COALESCE(SUM(vote.total_score), 0) AS total_score,
COALESCE(ROUND(AVG(vote.total_score), 1), 0) AS average_score
FROM vehicles
LEFT JOIN vote ON vote.vehicle_id = vehicles.id
WHERE YEAR(vehicles.created_date) = ?
AND vehicles.status = 1
GROUP BY vehicles.id, vehicles.name, vehicles.vehicle_maker, vehicles.vehicle_model, vehicles.vehicle_year, vehicles.category
HAVING score_count > 0
ORDER BY vehicles.category ASC, total_score DESC, average_score DESC, score_count DESC, vehicles.id ASC
";
if ($stmt = mysqli_prepare($conn, $categorySql)) {
mysqli_stmt_bind_param($stmt, "i", $currentYear);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result)) {
$category = $row['category'] ?: 'Uncategorized';
if (!isset($categoryResults[$category])) {
$categoryResults[$category] = [];
}
if (count($categoryResults[$category]) < 3) {
$categoryResults[$category][] = $row;
}
}
}
$peopleChoiceRows = [];
$peopleSql = "
SELECT name, vehicle_maker, vehicle_model, vehicle_year, category, fav_vote
FROM vehicles
WHERE YEAR(created_date) = ?
AND status = 1
ORDER BY CAST(fav_vote AS UNSIGNED) DESC, id ASC
LIMIT 3
";
if ($stmt = mysqli_prepare($conn, $peopleSql)) {
mysqli_stmt_bind_param($stmt, "i", $currentYear);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result)) {
$peopleChoiceRows[] = $row;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Announcer Results</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<style>
body {
padding: 28px;
}
h1, h2 {
margin-top: 0;
}
.section {
border-top: 2px solid #222;
margin-top: 28px;
padding-top: 18px;
}
@media print {
.no-print {
display: none;
}
}
</style>
</head>
<body>
<div class="no-print" style="margin-bottom: 18px;">
<button onclick="window.print()" class="btn btn-info">Print</button>
<a href="voting_dashboard.php" class="btn btn-default">Back</a>
</div>
<h1>Announcer Results</h1>
<p><?php echo date('F j, Y g:i A'); ?></p>
<div class="section">
<h2>Category Winners</h2>
<?php foreach ($categoryResults as $category => $rows): ?>
<h3><?php echo htmlspecialchars($category); ?></h3>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Place</th>
<th>Owner</th>
<th>Vehicle</th>
<th>Total Score</th>
</tr>
</thead>
<tbody>
<?php foreach ($rows as $index => $row): ?>
<tr>
<td><?php echo $index + 1; ?></td>
<td><?php echo htmlspecialchars($row['name']); ?></td>
<td><?php echo htmlspecialchars(trim($row['vehicle_year'] . ' ' . $row['vehicle_maker'] . ' ' . $row['vehicle_model'])); ?></td>
<td><?php echo (int) $row['total_score']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endforeach; ?>
</div>
<div class="section">
<h2>People's Choice</h2>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Place</th>
<th>Owner</th>
<th>Vehicle</th>
<th>Votes</th>
</tr>
</thead>
<tbody>
<?php foreach ($peopleChoiceRows as $index => $row): ?>
<tr>
<td><?php echo $index + 1; ?></td>
<td><?php echo htmlspecialchars($row['name']); ?></td>
<td><?php echo htmlspecialchars(trim($row['vehicle_year'] . ' ' . $row['vehicle_maker'] . ' ' . $row['vehicle_model'])); ?></td>
<td><?php echo (int) $row['fav_vote']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</body>
</html>