Mercurial > hg > fapweb
view results.inc.php @ 20:02ff0c29df8a
s/voter/entry/.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 06 Dec 2012 18:45:43 +0200 |
parents | d76020022881 |
children | e6ffab8414cc |
line wrap: on
line source
<? $text = TRUE; $showResults = stGetSetting("showResults"); $showAuthors = stGetSetting("showResAuthors"); echo "<h1>Results</h1>\n"; if (!$showResults) { echo "<p>Sorry, no results available! Nothing to see here, move along.</p>"; } else { if (($res = stExecSQL("SELECT * FROM compos WHERE enabled<>0 ORDER BY name DESC")) !== FALSE) { if ($text) echo "<pre>\n"; foreach ($res as $compo) { $sql = "SELECT entries.*,SUM(votes.value) AS votesum ". "FROM entries LEFT JOIN votes ON entries.id=votes.entry_id ". "WHERE entries.compo_id=".$compo["id"]." ". "GROUP BY votes.entry_id ". "ORDER BY votesum DESC"; if (($fres = stExecSQL($sql)) !== FALSE) { if ($text) { echo "<b> ".$compo["name"]." </b>\n"; echo str_repeat("=", strlen($compo["name"]) + 2)."-- - .\n\n"; $index = 1; foreach ($fres as $entry) { printf("%3s. %s by %s (%d pts)\n", $index, chentities(sprintf("%-35s", $entry["name"])), chentities(sprintf("%-25s", $showAuthors ? $entry["author"] : "-")), $entry["votesum"]); $index++; } echo "\n\n"; } else { echo "<h2>".$compo["name"]."</h2>\n". "<table class=\"attendees\" style=\"width: 80%;\">\n". " <tr>\n". " <th style=\"width: 1%;\">#</th>\n". " <th style=\"width: 3%;\">Points</th>\n". " <th>Name</th>\n". " <th>Author</th>\n". " </tr>\n"; $index = 1; foreach ($fres as $entry) { echo "<tr>". "<td>#".$index."</td>". "<td>".$entry["votesum"]."</td>". "<td>".chentities($entry["name"])."</td>". "<td>".($showAuthors ? chentities($entry["author"]) : "-")."</td>". "</tr>\n"; $index++; } echo "</table>\n"; } } } if ($text) echo "</pre>\n"; } } ?>