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

ToDoList Manager

ToDoList

Title Description

value="">

value="">

Add Product

List Categories

© ToDoList.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!