I need button to begin a mysql query to then insert the results into a javacript code block which is to be displayed on the same page that the button is on. mysql queries come f
You need to use a technology called AJAX. I'd recommend jQuery's .ajax()
method. Trying to do raw XHR is painful at best.
Here is how you'll want to structure your code:
Basically, HTTP is stateless, so once the page is loaded, it's done. You'll have to make successive requests to the server for dynamic data.