qna/admin/all.php
2024-12-09 13:33:24 -05:00

65 lines
No EOL
2.5 KiB
PHP

<?php
$query = "
SELECT * FROM data;
";
$qresp = pg_query($db, $query);
$rows = pg_fetch_all($qresp);
$totalUnresponded = 0;
$totalPriv = 0;
$totalRespondedPub = 0;
for ($i=count($rows); $i>=0; $i--) {
if ($rows[$i]["isrespondedto"] === "f" && $rows[$i]["ispublic"] === "t") {
$totalUnresponded++;
} else if ($rows[$i]["ispublic"] === "f") {
$totalPriv++;
} else {
$totalRespondedPub++;
}
}
echo("<h3 class=\"sect\">not responded to ({$totalUnresponded})</h3>");
for ($i=count($rows); $i>=0; $i--) {
if ($rows[$i]["isrespondedto"] === "f" && $rows[$i]["ispublic"] == "t") {
echo("<div class=\"question\">");
if ($rows[$i]["iscwed"] === "t") {
echo("<details><summary>cw: " . $rows[$i]["cw"] . "</summary><span class=\"cwfiller\"></span>");
}
echo(htmlspecialchars($rows[$i]["text"]));
echo("<div class=\"time\">" . $rows[$i]["time"] . "</div>");
echo("<a class=\"permalink\" href=\"index.php?page=edit&id=" . ($i + 1) . "\">edit</a> / <a class=\"permalink\" href=\"index.php?page=respond&id=" . ($i + 1) . "\">respond</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . ($i + 1) . "\">delete</a></div>");
}
}
echo("<h3 class=\"sect\">private ({$totalPriv})</h3>");
for ($i=count($rows); $i>=0; $i--) {
if ($rows[$i]["ispublic"] === "f") {
echo("<div class=\"question\">");
if ($rows[$i]["iscwed"] === "t") {
echo("<details><summary>cw: " . $rows[$i]["cw"] . "</summary><span class=\"cwfiller\"></span>");
}
echo(htmlspecialchars($rows[$i]["text"]));
echo("<div class=\"time\">" . $rows[$i]["time"] . "</div>");
echo("<a class=\"permalink\" href=\"index.php?page=edit&id=" . ($i + 1) . "\">edit</a></div>");
}
}
echo("<h3 class=\"sect\">public ({$totalRespondedPub})</h3>");
for ($i=count($rows); $i>=0; $i--) {
if ($rows[$i]["ispublic"] === "t" && $rows[$i]["isrespondedto"] === "t") {
echo("<div class=\"question\">");
if ($rows[$i]["iscwed"] === "t") {
echo("<details><summary>cw: " . $rows[$i]["cw"] . "</summary><span class=\"cwfiller\"></span>");
}
echo(htmlspecialchars($rows[$i]["text"]));
echo("<div class=\"time\">" . $rows[$i]["time"] . "</div>");
echo("<div class=\"response\">" . htmlspecialchars($rows[$i]["responsetext"]) . "");
echo("<div class=\"time\">" . $rows[$i]["responsetime"] . "</div></div>");
echo("<a class=\"permalink\" href=\"index.php?page=edit&id=" . ($i + 1) . "\">edit</a></div>");
}
}
?>