Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So ive tried everything to get this Remove Task button (just to the right of the existing Add Task button). and the Remove Task button

So ive tried everything to get this Remove Task button (just to the right of the existing Add Task button). and the Remove Task button removes the task at the top of the list (LIFO or Last In First Out). i generated a replica of the add task option with the implmentation of stack it is not working for me . i need some solution to this problem .

I added the Remove Tak button already just need help getting the solution to remove the task from the top :

image text in transcribed

task_list.php:

Task List Manager

Task List Manager

0) : ?>

Errors:

Tasks:

There are no tasks in the task list.

    $task ) : ?>

Add Task:

0 && empty($task_to_modify)) : ?>

Select Task:

Task to Modify:

index.php:

//get action variable from POST $action = filter_input(INPUT_POST, 'action');

//initialize error messages array $errors = array();

//process switch( $action ) { case 'Add Task': $new_task = filter_input(INPUT_POST, 'newtask'); if (empty($new_task)) { $errors[] = 'The new task cannot be empty.'; } else { // $task_list[] = $new_task; //array_push($task_list, $new_task); array_unshift($task_list, $new_task); //add the task in first index shifted the array } break;

case 'Delete Task': $task_index = filter_input(INPUT_POST, 'taskid', FILTER_VALIDATE_INT); if ($task_index === NULL || $task_index === FALSE) { $errors[] = 'The task cannot be deleted.'; } else { unset($task_list[$task_index]); $task_list = array_values($task_list); } break;

case 'Modify Task': $task_index = filter_input(INPUT_POST, 'taskid', FILTER_VALIDATE_INT); if ($task_index === NULL || $task_index === FALSE) { $errors[] = 'The task cannot be modified.'; } else { $task_to_modify = $task_list[$task_index]; } break; case 'Save Changes': $i = filter_input(INPUT_POST, 'modifiedtaskid', FILTER_VALIDATE_INT); $modified_task = filter_input(INPUT_POST, 'modifiedtask'); if (empty($modified_task)) { $errors[] = 'The modified task cannot be empty.'; } elseif($i === NULL || $i === FALSE) { $errors[] = 'The task cannot be modified.'; } else { $task_list[$i] = $modified_task; $modified_task = ''; } break; case 'Cancel Changes': $modified_task = ''; break; case 'Promote Task': $task_index = filter_input(INPUT_POST, 'taskid', FILTER_VALIDATE_INT); if ($task_index === NULL || $task_index === FALSE) { $errors[] = 'The task cannot be promoted.'; } elseif ($task_index == 0) { $errors[] = 'You can\'t promote the first task.'; } else { // get the values for the two indexes $task_value = $task_list[$task_index]; $prior_task_value = $task_list[$task_index-1];

// swap the values $task_list[$task_index-1] = $task_value; $task_list[$task_index] = $prior_task_value; break; } case 'Sort Tasks': sort($task_list); break; }

include('task_list.php'); ?>

Chegg Study | Guided Solutions and Study Help | Chegg.com Task List Manager Tasks: 1. Write chapter 2. Edit chapter 3. Proofread chapter Add Task: Task: Add Task Remove Task Select Task: Task: Write chapter Modify Task Promote Task Delete Task Sort Tasks Chegg Study | Guided Solutions and Study Help | Chegg.com Task List Manager Tasks: 1. Write chapter 2. Edit chapter 3. Proofread chapter Add Task: Task: Add Task Remove Task Select Task: Task: Write chapter Modify Task Promote Task Delete Task Sort Tasks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions