function show_replies($guests, $event, $reply, $org)
{
    $rows = gtable_query($guests, "event", $event);
    $rows = rowids_get_sorted_rows($guests, $rows, "name", false, array("id", "name", "email", "emails", "reply", "heads", "comments"));
    foreach ($rows as $row) {
        if ($row["reply"] != $reply) {
            continue;
        }
        if (!$row["reply"] && !$row["emails"] && $row["id"] != $org) {
            continue;
        }
        $name = $row["name"];
        $email = htmlspecialchars($row["email"]);
        $heads = $row["heads"];
        $comments = htmlspecialchars($row["comments"]);
        echo "<B><A HREF=\"mailto:{$email}\">{$name}</A>";
        if ($row["id"] == $org) {
            echo " (the organizer)";
        }
        if ($heads > 1) {
            echo " + " . ($heads - 1) . ($heads > 2 ? " people" : " person");
        }
        echo "</B><BR>\n";
        if ($comments) {
            echo "<DIV CLASS=\"comments\">{$comments}</DIV>\n";
        }
    }
}
function show_replies($guests, $event, $reply, $org)
{
    $rows = gtable_query($guests, "event", $event);
    $rows = rowids_get_sorted_rows($guests, $rows, "name", false, array("id", "name", "hash", "email", "emails", "reply", "heads", "comments"));
    foreach ($rows as $row) {
        if ($row["reply"] != $reply) {
            continue;
        }
        $id = $row["id"];
        $name = $row["name"];
        $hash = $row["hash"];
        $email = htmlspecialchars($row["email"]);
        $emails = $row["emails"];
        $heads = $row["heads"];
        $comments = htmlspecialchars($row["comments"]);
        echo "<DIV STYLE=\"float: right;\"><INPUT TYPE=\"CHECKBOX\" NAME=\"check_{$id}\"></DIV>\n";
        echo "<B><INPUT TYPE=\"TEXT\" SIZE=20 NAME=\"name_{$id}\" VALUE=\"{$name}\" onChange='notifyChange()'>";
        if ($id == $org) {
            echo " (the organizer)";
        }
        if ($heads > 1) {
            echo " + " . ($heads - 1) . ($heads > 2 ? " people" : " person");
        }
        echo "</B><BR>\n";
        if ($comments) {
            echo "<DIV CLASS=\"comments\">{$comments}</DIV>\n";
        }
        $s = $emails == 1 ? "" : "s";
        echo "<DIV CLASS=\"info\">[ {$emails} email{$s} to ";
        if ($id == $org) {
            echo "{$email}";
        } else {
            echo "<INPUT TYPE=\"TEXT\" SIZE=30 NAME=\"email_{$id}\" VALUE=\"{$email}\" onChange='notifyChange()'>";
        }
        echo " | <A HREF=\"index.php?invite={$hash}\" TARGET=\"_new\">edit reply</A>]</DIV>\n";
    }
}