Looking at the code, I wonder if you can achieve your objective by using one of the Database/Tables extensions (see https://www.wysiwygwebbuilder.com/extensions.html ) either paid or unpaid. With some you can insert your own MySQL query and you can rely upon the extension to deal with the ...
I will need to test this outside of the web builder app.
You should note that you cannot "Preview" php locally in the software you will need to publish to your host/server before you will see the results. Or you will need to install the likes of xampp to set with on your PC.
I have a HTML object and inside it is this PHP script, database details blanked out for here :- <?php echo "DB Test"; // Database connection details $servername = ""; $username = " "; $password = ""; $dbname = ""; echo "DB Test connecting"; // Create connection $conn = new mysqli($servername ...