Is it possible to connect Database to HTML?

Hi everyone,
i have a question from my problem, is it possible to connect a PHP file which contain MySQL script into HTML file? if yes, does the connection really works? in example, i’m trying to send the form data from HTML into database by using PHP as a bridge for the two of it. from many of examples that i have search, there is almost no examples like the problem that i had, most of it recommends to use PHP file from scratch instead of HTML-PHP connection file.

My code goes with something like this

    $db = mysqli_connect('localhost','root',' ','kantor');
                $query = "SELECT * FROM `form`;";
                $result = mysqli_query($db, $query);
                while($row = mysqli_fetch_assoc($result)) 


Sorry if it’s sounds kind of silly, but i really confused about it because i prefer if i can do it by using HTML and PHP rather than going all PHP for both of the Front-end and Back-end. Thank you very much for reading and your time.

Hey @Kevin Witomo welcome to the Xojo community - the friendliest on the Web. Your question seems to be not related to Xojo, so while you may get some friendly advice from here you aren’t really in scope.

Sorry if my question not kind of related to Xojo, i’m kind of starting in here too. anyway, thanks for the information!

Yes, you can combine php and html in a single file. It must have a php extension, though, not htm or html.

I really don’t like to see PHP and HTML mashed together, I much prefer to see a single page web app as a front end interacting with the back end using JSON.