Listing and form without template engine

For some reasons i don’t want to use a template engine. On a page i have a listing table and if i want to edit a record i want a form instead of listing table may be with $_GET[‘do’] = “edit” and script will show the form instead of listing table. As i don’t want to use a template engine what is the best way to make this? I should have a file for listing and a file for form and in php require_once whatever of them when needed? Is there a better way? Can someone write a class to handle this? Please advice the best way.

You seem to be saying you want to display a table listing a record of some kind and then have a link or button on each row saying “Edit” which you can press to take you to a form where you can then edit that record. Am I understanding you correctly?

The simplest way to do this is have files list-records.php and edit-record.php. list-records.php would produce the table and generate a link to edit-record.php?id=X for each row. edit-record.php would then look at $_GET[‘id’] in order to prepopulate the edit form it produces with the appropriate data from the database. A POST request to edit-record.php would be used to send an update query to the database.

You can use $_SERVER[‘REQUEST_METHOD’] === ‘POST’ to tell if the request is a post request or simply check for the existence of an important POST var e.g. isset($_POST[‘record-name’]).