function management_view($db)
{
    // Table for management
    $table = <<<EOD
\t<table id='keysTable' class="fancy" style="font-size:83%;" border=1>
\t\t<tr>
\t\t\t<th>
\t\t\t\t<a href="">Name</a>
\t\t\t</th>
\t\t\t<th>
\t\t\t\t<a href="">Type</a>
\t\t\t</th>
\t\t\t<th>
\t\t\t\t<a href="">Characters</a>
\t\t\t</th>
\t\t\t<th>
\t\t\t\t<a href="">Notes</a>
\t\t\t</th>
\t\t</tr>
EOD;
    $apiResults = retrieve_api_keys($db);
    if ($apiResults) {
        $alt_b = false;
        foreach ($apiResults as $row) {
            $alt_b = !$alt_b;
            $rand = rand();
            $name = $row['keyName'];
            $type = $row['type'];
            $Characters = $row['characters'];
            $key = $row['apiKey'];
            $notes = $row['notes'];
            if (!$notes) {
                $trunNotes = "no notes";
            } elseif (strlen($notes) > 140) {
                $trunNotes = substr($notes, 0, 130) . " . . . ";
            } else {
                $trunNotes = $notes;
            }
            $id = $row['id'];
            $class = $alt_b ? "main" : "alt";
            $table .= <<<EOD
\t\t\t\t\t<tr id="row{$id}" class="{$class}">
\t\t\t\t\t<td style="color: #FFA500"><a href="index.php?key={$key}" id="name{$id}">{$name}</a><input type="text" style="display:none;" id="nameEdit{$id}" value="{$name}"/>
\t\t\t\t\t<input id="nameButton{$id}" style="display:none;" type="button" value="Edit" onclick="editName({$id}); hide('nameEdit{$id}'); hide('nameButton{$id}');show('name{$id}') return false;"></th>
\t\t\t\t\t<td>{$type}</td>
\t\t\t\t\t<td>{$Characters}</td>
\t\t\t\t\t<td id="note{$id}">{$trunNotes}</td>
\t\t\t\t\t<td><a onclick="show_notes({$id}); return false;" href="manage.php?editNotes&id={$id}">Edit notes</a></td>
\t\t\t\t\t<td><a onclick="removeKey({$id}); return false;" href="manage.php?removeKey&id={$id}">Remove Key</a></td>
\t\t\t\t\t<td><a onclick="show('nameEdit{$id}'); hide('name{$id}'); show('nameButton{$id}'); return false;" href="manage.php?editName&id={$id}">Edit Name</a></td>
\t\t\t\t\t</tr>
EOD;
        }
        $table .= <<<EOD
\t\t\t\t<div onclick="hide_notes(); return false;" id="notesDiv" class="fade_div">&nbsp;</div>
\t\t\t\t<div id="notes" class="floating_login_div">
\t\t\t\t<div class="exitbutton"><a href="#" onclick="hide_notes(); return false;">[X]</a></div>
\t\t\t\tNotes<br/>
\t\t\t\t<textarea name="noteText" Cols="50" Rows="15" id="noteText" style="resize:none;background-color:#222222; color:#EEEEEE;" onKeyDown="limitText(this,3000)"></textarea>
\t\t\t\t<br>
\t\t\t\t<input type="button" value="Edit" onclick="saveNotes({$id}); hide_notes();">
\t\t\t\t</div>
EOD;
        $table .= <<<EOD
\t\t\t\t<div onclick="hide_name(); return false;" id="nameDiv" class="fade_div">&nbsp;</div>
\t\t\t\t<div id="edi" class="floating_login_div">
\t\t\t\t<div class="exitbutton"><a href="#" onclick="hide_notes(); return false;">[X]</a></div>
\t\t\t\tNotes<br/>
\t\t\t\t<textarea name="noteText" Cols="50" Rows="15" id="noteText" style="resize:none;background-color:#222222; color:#EEEEEE;" onKeyDown="limitText(this,3000)"></textarea>
\t\t\t\t<br>
\t\t\t\t<input type="button" value="Edit" onclick="saveNotes({$id}); hide_notes();">
\t\t\t\t</div>
EOD;
    } else {
        $table .= "<tr><td colspan=4> No Keys Found </td></tr>";
    }
    $table .= "</table>";
    $table .= "\n\t</body></html>\n\t";
    return $table;
}
function management_view($db)
{
    // Table for management
    $table = <<<EOD
\t<table id='keysTable' class="fancy" style="font-size:83%;" border=1>
\t\t<tr>
\t\t\t<th>
\t\t\t\t<a href="">Name</a>
\t\t\t</th>
\t\t\t<th>
\t\t\t\t<a href="">Type</a>
\t\t\t</th>
\t\t\t<th>
\t\t\t\t<a href="">Characters</a>
\t\t\t</th>
\t\t\t<th>
\t\t\t\t<a href="">Notes</a>
\t\t\t</th>
\t\t</tr>
EOD;
    $apiResults = retrieve_api_keys($db);
    if ($apiResults) {
        $alt_b = false;
        foreach ($apiResults as $row) {
            $alt_b = !$alt_b;
            $rand = rand();
            $name = $row['keyName'];
            $type = $row['type'];
            $Characters = $row['characters'];
            $key = $row['apiKey'];
            $notes = $row['notes'];
            if (!$notes) {
                $trunNotes = "no notes";
            } elseif (strlen($notes) > 140) {
                $trunNotes = substr($notes, 0, 130) . " . . . ";
            } else {
                $trunNotes = $notes;
            }
            $id = $row['id'];
            $class = $alt_b ? "main" : "alt";
            $table .= <<<EOD
\t\t\t\t\t<tr keyID={$id} class="{$class}">
\t\t\t\t\t<td style="color: #FFA500"><a href="index.php?key={$key}" class="keyName">{$name}</a></td>
\t\t\t\t\t<td>{$type}</td>
\t\t\t\t\t<td>{$Characters}</td>
\t\t\t\t\t<td class="keyNotes">{$trunNotes}</td>
\t\t\t\t\t<td><a keyID={$id} class="editKey" href="manage.php?editNotes&id={$id}">Edit Key</a></td>
\t\t\t\t\t<td><a keyID={$id} class="removeKey" href="manage.php?removeKey&id={$id}">Remove Key</a></td>
\t\t\t\t\t</tr>
EOD;
        }
        $table .= '<div class="fadeDiv">&nbsp;</div><div id="keyInfoBox" class="floating_login_div" style="display: none;">';
        $table .= '<div class="exitbutton"><a href="#">[X]</a></div>';
        $table .= edit_key_form();
        $table .= '</div>';
    } else {
        $table .= "<tr><td colspan=4> No Keys Found </td></tr>";
    }
    $table .= "</table>";
    $table .= "\n\t</body></html>\n\t";
    return $table;
}