What you're triyng to do is not correct.
You start from the wrong point that you're dealing with a stand-alone application, running onto your PC.
This isn't true.
Your template isn't executed onto your pc but on the server.
So you must advise in some way the server that you want it to perform a query on the connected database and do something with the data it will retrieve.
You do this by sending some data to the server with a form post, a http url link or something.
If you want to do it via a form button use a submit button and set the action of the form to a template which executes the query.
This may be the same template itself.
Put this on the top of the template itself:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.