コード例 #1
0
ファイル: todo.php プロジェクト: JoshuaRichards/php-todo
function listTodo()
{
    if (isset($_SESSION['userid'])) {
        $todoItems = getTodoItems($_SESSION['userid']);
        if (count($todoItems) === 0) {
            echo '<div class="card"><p>no items added yet</p></div>';
        }
        for ($i = 0; $i < count($todoItems); $i++) {
            $row = $todoItems[$i];
            echo '<div class="card">';
            echo '<p>' . $row['description'] . '</p>';
            echo '<input type="checkbox" onClick="setComplete(this, ' . $i . ')" ';
            if ($row['completed']) {
                echo 'checked ';
            }
            echo '/></div>';
        }
        $_SESSION['todolist'] = $todoItems;
    } else {
        echo '<div class="card"><p>log in to see your todo list</p></div>';
    }
}
コード例 #2
0
         printf("PR%04d: ", $list[$i]["itemId"]);
         echo "<a href=\"admin_todo_lists.php?id=" . $list[$i]["itemId"] . "\">" . $list[$i]["itemDesc"] . "</a> (" . $todo_item_status[$list[$i]["itemStatus"]] . ")<br>";
     }
     echo "<br>" . count($list) . " items in list.<br>";
     echo $lookup_pr;
     echo "<br>";
     echo "<a href=\"admin_todo_lists.php?list=" . $listId . "\">&raquo; Back to TODO lists " . $todo_list[$listId] . " index</a><br>";
     echo "<a href=\"admin_todo_lists.php\">&raquo; Back to TODO lists index</a><br>";
     echo "<a href=\"admin.php\">&raquo; Back to Administration screen</a><br>";
 } else {
     /* Show the OPEN and ASSIGNED items in this category */
     if (isset($_POST["desc"])) {
         addTodoItem($db, $listId, $_SESSION["userId"], $_POST["desc"], $_POST["details"], $_POST["category"]);
     }
     echo "<b class=\"topic\">Administration screen - TODO list for '" . $todo_list[$listId] . "' category</b><br><br>";
     $list = getTodoItems($db, $listId);
     for ($i = 0; $i < count($list); $i++) {
         printf("PR%04d: ", $list[$i]["itemId"]);
         echo "<a href=\"admin_todo_lists.php?id=" . $list[$i]["itemId"] . "\">" . $list[$i]["itemDesc"] . "</a> (" . $todo_item_status[$list[$i]["itemStatus"]] . ")<br>";
     }
     $closeditems = getClosedTodoCategoryItems($db, $listId);
     echo "<br>" . count($list) . " items (ignoring " . $closeditems . " closed items).<br>";
     if ($closeditems) {
         echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?list=" . $listId . "&showclosed=1\">&raquo; List closed items for this category</a><br>";
     }
     echo "<form method=\"post\" action=\"" . $_SERVER["PHP_SELF"] . "?list=" . $listId . "\">";
     echo "<b class=\"topic\">Add a item to the list</b><br><br>";
     echo "Description: <input type=\"text\" name=\"desc\" size=45><br>";
     echo "Details:<br>";
     echo "<textarea name=\"details\" cols=60 rows=8></textarea><br>";
     echo "Category: ";
コード例 #3
0
ファイル: data.php プロジェクト: Vitosh/PHP
<?php

include 'db_connection.php';
function getTodoItems($user_id)
{
    $SQL = "SELECT * FROM todos WHERE user_id = " . $user_id . "";
    $result = mysql_query($SQL);
    echo "<form action='#' method = 'POST'>";
    while ($data = mysql_fetch_assoc($result)) {
        echo "<table>";
        echo "<tr>";
        echo "<td><input type='checkbox' name='check_list[]' value='" . $data["id"] . "'></td>";
        echo "<td>" . $data["todo_item"] . "</td>";
        echo "</tr>";
        echo "</table>";
    }
    echo "</hr>";
    echo "</form>";
}
function getCleared()
{
    echo "Please, select a user with a todo list :)";
}
if ($_GET["choice"]) {
    echo getTodoItems($_GET["choice"]);
} else {
    echo getCleared();
}
コード例 #4
0
ファイル: list.php プロジェクト: Vitosh/PHP
<?php

include 'db_connection.php';
include 'db.php';
if (!$_COOKIE['islogged']) {
    header("location:login.php");
}
echo "Welcome," . $_COOKIE['login'] . "<br/>";
echo "Below you may find your TODO list :)";
echo "<br/><br/>To Do list:<br/><br/>";
getTodoItems($_COOKIE['my_id']);
if (isset($_POST['submit_description'])) {
    addTodoItem($_COOKIE['my_id'], $_POST['description']);
    header("Refresh:0");
}
if (isset($_POST['check_list'])) {
    foreach ($_POST['check_list'] as $selected) {
        deleteTodoItem($_COOKIE['my_id'], $selected);
    }
    header("Refresh:0");
}
?>
<html>
<body>
    <hr />
    <form method="post">
        <table>
            <tr><td>Description:</td><td><input type="text" name="description" /></td></tr>
                <input type="submit" name="submit_description" value="Add"/>
            </td></tr>
        </table>