Add a counter for colors named

This commit is contained in:
Lncvrt committed 2026-02-18 21:18:37 -07:00
1 parent b353bd4485
commit 5b9cda2ed2
2 files changed
+10

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
<?php
function formatWithCommas($number) {
return number_format($number, 0, '.', ',');
}
+6
View File
@@ -1,6 +1,7 @@
<?php
include __DIR__ . "/../config/captcha.php";
include __DIR__ . "/../incl/db.php";
include __DIR__ . "/../incl/util.php";
$conn = connectToDatabase();
@@ -8,6 +9,10 @@ $stmt = $conn->prepare("SELECT * FROM colors ORDER BY timestamp DESC");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$total = 255 * 255 * 255;
$named = count($result);
$remaining = $total - $named;
$lastInsertId = $_GET['highlight'] ?? null;
?>
<!DOCTYPE html>
@@ -111,6 +116,7 @@ $lastInsertId = $_GET['highlight'] ?? null;
</head>
<body>
<h1>Name A Color!</h1>
<p><?= formatWithCommas($named) ?>/<?= formatWithCommas($total) ?> colors named (<?= formatWithCommas($remaining) ?> left)</p>
<hr>
<h2>Name your own color!</h2>
<form action="upload.php" method="post">