{ "key_pair_value_system": true, "answer_rating_count": "", "question_feedback_html": { "html_star": "", "html_star_feedback": "" }, "answer_average_rating_value": "", "answer_date_js": "2024-09-06T00:07:01-04:00", "answer_date": "2024-09-06 00:07:01", "is_docs_available": null, "is_excel_available": null, "is_pdf_available": null, "count_file_available": 0, "main_page": "student_question_view", "question_id": "9248335", "url": "\/study-help\/questions\/in-addition-to-the-php-code-below-i-wish-to-9248335", "question_creation_date_js": "2024-09-06T00:07:01-04:00", "question_creation_date": "Sep 06, 2024 12:07 AM", "meta_title": "[Solved] In addition to the PHP code below, I wish | SolutionInn", "meta_description": "Answer of - In addition to the PHP code below, I wish to add a Remove Task button after the Add Task button in the Add Task portio | SolutionInn", "meta_keywords": "addition,php,code,below,wish,add,remove,task,button,portion,page,modify", "question_title_h1": "In addition to the PHP code below, I wish to add a Remove Task button after the Add Task button in the Add Task portion", "question_title": "In addition to the PHP code below, I wish to add a", "question_title_for_js_snippet": "In addition to the PHP code below, I wish to add a Remove Task button after the Add Task button in the Add Task portion of the page Then, modify the PHP for the page so the Add Task button adds the task to the top of the task list (currently, it adds the task to the bottom of the list), and the Remove Task button removes the task at the top of the list (LIFO) Task List Manager Task List Manager Errors Tasks There are no tasks in the task list Add Task ", "question_description": "

In addition to the PHP code below, I wish to add a Remove Task button after the Add Task button in the Add Task portion of the page. Then, modify the PHP for the page so the Add Task button adds the task to the top of the task list (currently, it adds the task to the bottom of the list), and the Remove Task button removes the task at the top of the list (LIFO).<\/p>

\/\/get action variable from POST $action = filter_input(INPUT_POST, 'action');<\/p>

\/\/initialize error messages array $errors = array();<\/p>

\/\/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 { array_push($task_list, $new_task); } 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': 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': 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': case 'Cancel Changes': $modified_task = ''; break; \/\/ case 'Promote Task': 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 cannot 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];<\/p>

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

}<\/p>

include('task_list.php'); ?><\/p>

Task List Manager<\/title> <link rel=\"stylesheet\" type=\"text\/css\" href=\"main.css\"> <\/head> <body> <header> <h1>Task List Manager<\/h1> <\/header><\/p> <p> <main> <p><?php print_r($task_list); ?><\/p> <!-- part 1: the errors --> <?php if (count($errors) > 0) : ?> <h2>Errors:<\/h2> <ul> <?php foreach($errors as $error) : ?> <li><?php echo $error; ?><\/li> <?php endforeach; ?> <\/ul> <?php endif; ?><\/p> <p> <!-- part 2: the tasks --> <h2>Tasks:<\/h2> <?php if (count($task_list) == 0) : ?> <p>There are no tasks in the task list.<\/p> <?php else: ?> <ul> <?php foreach( $task_list as $id => $task ) : ?> <li><?php echo $id + 1 . '. ' . $task; ?><\/li> <?php endforeach; ?> <\/ul> <?php endif; ?> <\/p> <p> <!-- part 3: the add form --> <h2>Add Task:<\/h2> <form action=\".\" method=\"post\" > <?php foreach( $task_list as $task ) : ?> <input type=\"hidden\" name=\"tasklist[]\" value=\"<?php echo $task; ?>\"> <?php endforeach; ?> <label>Task:<\/label> <input type=\"text\" name=\"newtask\" id=\"newtask\"> <label> <\/label> <input type=\"submit\" name=\"action\" value=\"Add Task\"> <\/form> <\/p> <p> <!-- part 4: the modify\/promote\/delete form --> <?php if (count($task_list) > 0 && empty($task_to_modify)) : ?> <h2>Select Task:<\/h2> <form action=\".\" method=\"post\" > <?php foreach( $task_list as $task ) : ?> <input type=\"hidden\" name=\"tasklist[]\" value=\"<?php echo $task; ?>\"> <?php endforeach; ?> <label>Task:<\/label> <select name=\"taskid\"> <?php foreach( $task_list as $id => $task ) : ?> <option value=\"<?php echo $id; ?>\"> <?php echo $task; ?> <\/option> <?php endforeach; ?> <\/select> <label> <\/label> <input type=\"submit\" name=\"action\" value=\"Modify Task\"> <input type=\"submit\" name=\"action\" value=\"Promote Task\"> <input type=\"submit\" name=\"action\" value=\"Delete Task\"><\/p> <p> <label> <\/label> <input type=\"submit\" name=\"action\" value=\"Sort Tasks\"> <\/form> <?php endif; ?><\/p> <p> <!-- part 5: the modify save\/cancel form --> <?php if (!empty($task_to_modify)) : ?> <h2>Task to Modify:<\/h2> <form action=\".\" method=\"post\" > <?php foreach( $task_list as $task ) : ?> <input type=\"hidden\" name=\"tasklist[]\" value=\"<?php echo $task; ?>\"> <?php endforeach; ?> <label>Task:<\/label> <input type=\"hidden\" name=\"modifiedtaskid\" value=\"<?php echo $task_index; ?>\"> <input type=\"text\" name=\"modifiedtask\" value=\"<?php echo $task_to_modify; ?>\"> <label> <\/label> <input type=\"submit\" name=\"action\" value=\"Save Changes\"> <input type=\"submit\" name=\"action\" value=\"Cancel Changes\"> <\/form> <?php endif; ?><\/p> <p> <\/main> <\/body> <\/html><\/p>", "transcribed_text": "", "related_book": { "title": null, "isbn": null, "edition": null, "authors": null, "cover_image": null, "uri": null, "see_more_uri": "" }, "free_related_book": { "isbn": "", "uri": "", "name": "", "edition": "" }, "question_posted": "2024-09-06 00:07:01", "see_more_questions_link": "\/study-help\/questions\/computer-science-operating-system-2022-August-09", "step_by_step_answer": "The Answer is in the image, click to view ...", "students_also_viewed": [ { "url": "\/study-help\/psychology-2e\/9-differentiate-between-the-distributed-and-specialist-approaches-to-building-1988291", "description": "9. Differentiate between the distributed and specialist approaches to building a SIRP team. Which approach do you favor and why? Can you think of a third approach? Explain.", "stars": 0 }, { "url": "\/consider-an-employee-who-does-not-receive-employerbased-health-insurance", "description": "Consider an employee who does not receive employer-based health insurance and must divide her $700 per week in after-tax income between health insurance and other goods. Draw this workers opportunity...", "stars": 3 }, { "url": "\/study-help\/questions\/porform-the-following-nocounting-tanks-for-the-receivable-of-cavanaugh-9979355", "description": "Porform the following nocounting tanks for the receivable of Cavanaugh and Johnson, a law firm of December 31, 2021 Read the fedemens Requirements 1 and 2. T-accounts have been set up for Cash,...", "stars": 3 }, { "url": "\/study-help\/questions\/the-current-one-year-u-s-t-6379033", "description": "The current one - year U . S . T - Bill rate is 4 . 3 % . a . Calculate outright quotes for bid and ask and the number of points spread between each. b . What do you notice about the spread as quotes...", "stars": 3 }, { "url": "\/study-help\/questions\/a-tourist-named-mr-lopez-from-chile-visited-arlington-and-1035070", "description": "A tourist named Mr. Lopez from Chile visited Arlington and bought a ticket for the Dallas Cowboys game. During his stay, he also paid for his hotel, meals, and various items from local shops, which...", "stars": 3 }, { "url": "\/study-help\/questions\/problem-315-static-journal-entries-taccounts-financial-statements-lo31-lo32-1479811", "description": "Problem 3-15 (Static) Journal Entries; T-Accounts; Financial Statements [LO3-1, LO3-2, LO3-3, LO3-4] Froya Fabrikker A\/S of Bergen, Norway, is a small company that manufactures specialty heavy...", "stars": 3 }, { "url": "\/study-help\/questions\/marin-inc-sells-tickets-for-a-caribbean-cruise-on-shipaway-5303204", "description": "Marin Inc. sells tickets for a Caribbean cruise on ShipAway Cruise Lines to Cullumber Company employees. The total cruise package price to Cullumber Company employees is $84,000. Marin Inc. receives...", "stars": 3 }, { "url": "\/study-help\/questions\/required-information-the-following-information-applies-to-the-questions-displayed-1742314", "description": "Required information [The following information applies to the questions displayed below] Lakewood Tennis Club (LTC) operates an indoor tennis facility. The company charges a $170 annual membership...", "stars": 3 }, { "url": "\/study-help\/questions\/1-are-logistics-a-quantitative-factor-or-a-qualitative-factor-5195859", "description": "1) are logistics a quantitative factor or a qualitative factor in project management? explain using case example(s).", "stars": 3 } ], "next_back_navigation": { "previous": "\/study-help\/questions\/using-the-information-in-the-table-calculate-the-net-working-9248334", "next": "\/study-help\/questions\/bayan-and-gamila-are-students-at-applied-college-they-share-9248336" }, "breadcrumbs": [ { "name": "Study help", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers" }, { "name": "Computer Science", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers\/computer-science" }, { "name": "Databases", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/computer-science-databases" }, { "name": "In addition to the PHP code below, I wish to add a", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/in-addition-to-the-php-code-below-i-wish-to-9248335" } ], "skill_details": { "skill_id": "656", "skill_name": "Databases", "parent_id": "8" } }