Here's some logic to apply to your homework problem that should fix you up - but it's the logic, helping you to know where to look and what to look for.
(1) Look to where you create your checkout button. It should only happen after all of your items are listed and should not be part of the loop that creates the list of items.
(2) To make an element disappear, you have two basic routes. The hard way, putting the information in session variables and redrawing the page. I'd never do that. The proper way is to use the DOM via javascript. You can then set an on-click(), onchange() event in your button (you use links - which is part of the hard way!). The function can then change the visibility of a button, or its value. The best way, which is a more advance use of the second method is to use AJAX so you can redraw the table part of the screen to reflect changes without having to update the entire page. $_SESSION will work - but I rarely use them. Even that route, combined with using the DOM (....innerHTML='new table contents'), could be used to redraw your table without redrawing the page. The item disappears from the table (it no longer exists in it) - so it need not be hidden: it's gone.
A simplified description of all of this, with examples of events, event handlers, and DOM, can be found here:
W3Schools Online Web Tutorials[
^]
One last piece of advice: don't wait until the last minute to do homework. By now, it may be too late, even if you get extremely detailed help.