Of course you can put it on the same page. Just complicates things a little bit.
But you need to do a *SEPARATE* query to get the data for the edit.
Just as I put the query for the DELETE *before* the SELECT * so you would put the query for the edit before the main query and main display. (Or after the main display, if you prefer.)
Your code WILL NOT WORK as is. Because you do the DELETE *after* you do the SELECT * you will get *ALL* the records *AGAIN*. And then, after displaying them all, you do the DELETE. Too late to change the display.
The DELETE *must* be the first code on the page. The EDIT can be either second or last.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.