Question
I need help figuring out how I would be able to view all the todoItems I have on my todolist instead of just one category
I need help figuring out how I would be able to view all the todoItems I have on my todolist instead of just one category at a time with my dropdown list. I want to keep the drop down list and be able to select each individual category to display the todoitems underneath it. What I can to figure out it how to add a view all that goes a long with it without creating another button or drop down menu.
Index.php:
require_once('database.php');
// Get category ID
if (!isset($category_id)) {
$category_id = filter_input(INPUT_GET, 'category_id',
FILTER_VALIDATE_INT);
if ($category_id == NULL || $category_id == FALSE) {
$category_id = 1;
}
}
// Get name for selected category
$queryCategory = 'SELECT * FROM categories
WHERE categoryID = :category_id';
$statement1 = $db->prepare($queryCategory);
$statement1->bindValue(':category_id', $category_id);
$statement1->execute();
$category = $statement1->fetch();
$category_name = $category['categoryName'];
$statement1->closeCursor();
// Get all categories
$query = 'SELECT * FROM categories
ORDER BY categoryID';
$statement = $db->prepare($query);
$statement->execute();
$categories = $statement->fetchAll();
$statement->closeCursor();
// Get ToDoItems for selected category or all categories
if ($category_id) {
$queryProducts = 'SELECT * FROM todoitems
WHERE categoryID = :category_id
ORDER BY ItemNum';
$statement3 = $db->prepare($queryProducts);
$statement3->bindValue(':category_id', $category_id);
} else {
$queryProducts = 'SELECT * FROM todoitems
ORDER BY ItemNum';
$statement3 = $db->prepare($queryProducts);
}
$statement3->execute();
$products = $statement3->fetchAll();
$statement3->closeCursor();
?>
ToDoList Manager
ToDoList
View by Category
Title | Description | |
---|---|---|
Add Product
List Categories
© ToDoList.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started