I cannot for the life of me figure out why the DeleteTask function will not work, when it is almost the same as RetrieveTask; only called in different files.
Now:
src/controller/RetrieveTask:
prepares a PDO database query, and passes it to src/view/DisplayTask.php, which uses a for each-loop to echo the rows and an <a> element linking to src/redir/DeleteAndReturn.php.
This file simply executes src/controller/DeleteTask.php and src/controller/ReturnToIndex.php.
The file code and order is as follows:
RetrieveTask
<?php
function RetrieveTask($db)
{
    $sql = 'SELECT * FROM task';
    return $db->query($sql);
}
?>
Which gets passed to DisplayTask:
<?php
  function DisplayTask($db)
    {
         foreach (RetrieveTask($db) as $row)
        {
            echo "<li>" . $row['tsk-name'] . "<br>" . $row['tsk-desc'] . "<a id=".$row['id']." class='btn btn-danger' href='/todo/redir/DeleteAndReturn.php'>Delete</a>" . "</li>";
        }
    }
?>
Which get passed to index.php in the /todo/home directory. All I need to do is call DisplayTask($DbHandler) Where $DbHandler is an instant of the db class.
Now for src/controller/DeleteTask.php:
<?php
function DeleteTask($db)
{
    echo "Delete";
    $sql = ' DELETE FROM task where id= 2 ';
    return $db->query($sql);
}
?>
and src/controller/ReturnToIndex.php:
<?php
function ReturnToIndex()
{
    header('Location: /todo/home');
}
?>
Leads to redir/DeleteAndReturn.php
<?php
include_once('../src/model/db/DbConnect.php');
include_once('../src/controller/DeleteTask.php');
include_once('../src/controller/ReturnToIndex.php');
$DbHandler = new DbConnect();
DeleteTask($DbHandler);
$DbHandler->CloseConnection();
ReturnToIndex();
?>
I've tried passing the item id as a get parameter in a query string. Deleting all tables. Manually selecting the id. I can't get it to work. Any help would be much appreciated. I googled and looked up documentation for hours. I feel like it is something exceedingly simple that just went way over my head.
Full code is here: https://github.com/liengesbor.
 
    