Example #1
0
<?php

//turn off notices and errors (do not do this in production! ;)
error_reporting(0);
if ($_GET['query_name'] == 'todo_list') {
    $query = "SELECT id, user_id, todo_item FROM TODOS;";
    $result = database_connection($query);
    $arr_result = array();
    //Add some data here, in order to make some use of the AJAX
    $string_date_formatted = date("Y/m/d");
    addTodoItem(7, $string_date_formatted);
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        array_push($arr_result, array('some_ID' => $line['id'], 'some_userid' => $line['user_id'], 'some_text' => $line['todo_item']));
    }
    echo json_encode(array("todo_result" => $arr_result));
    exit;
}
function addTodoItem($user_id, $todo_text)
{
    $query = "INSERT INTO todos(user_id, todo_item) VALUES (" . $user_id . ",'" . $todo_text . "')";
    $result = database_connection($query);
}
function database_connection($query)
{
    mysql_connect('localhost', 'root', '') or die(write_error("No connection possible."));
    mysql_select_db('todo');
    return mysql_query($query);
}
function status($message, $status)
{
    die(json_encode(array('status' => $status, 'message' => $message)));
     echo "<b>OBSERVE - ONLY CLOSED ITEMS IN THIS LIST.</b><br><br>";
     $list = getClosedTodoItems($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>";
     }
     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>";
Example #3
0
File: list.php Project: 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>