Dynamically populating HTML Form at scale, using SQL values in PHP

This question is more related to process / logic of what I am hoping to achieve in terms of SCALE rather than how to code it.

In WordPress, I have several forms in html that are loaded when a user creates a custom post (essentially a new database entry for those not familiar with the CMS) for a new “incident” to be logged. I don’t want to have to map everything manually as this is using update_post_meta() to set the names and value for the database entry / post – so I am using the php loop foreach ($_POST as $name => $value) { when the form is submitted to populate all database table for this incident.

This works great, but now if the user saves the form and comes back to edit it later, I would like to echo the value if it exists like so:

<label for="reported_by">Reporting individual (full name)</label>
<?php $reported_by = get_post_meta($incident_id, 'reported_by', true); ?>
<input type="text" name="reported_by" value="<?php echo $reported_by; ?>">

Again this works just fine, but I have almost 500 fields across forms on this page so setting the unique variable (in this case $reported_by) for each manually is going to take me forever and will essentially increase the codebase by almost 50%, make this difficult to maintain and will not be efficient .

Any thoughts on how to approach this? Understandably I could construct the forms via php and echo in the HTML, but that also feels like a very manual process. PHP is server side, so I cant easily get the name values from the labels / inputs client side without using AJAX, which I feel is also going to be quiet manual.

So either way I am faced with a lot of monotony unless there is some way of approaching this that would make it easier to scale across all 500 fields without me having to set the variable names manually.

Thank you for your time!