There are many ways to do this. Many are insecure. One easy way is to use AJAX. You can load a
tag
with an external page using JQuery/AJAX. It basically allows you to load any external PHP file into any place on
your current page. In the external PHP code, you can access your database or do anything else you normally do
in a PHP file. You can pass items to the PHP file as posted data. Here is a sample I found on Stackoverflow that
gives you the basics… Hope that helps…
[php]
var somevariable = 1; // data sent to externalPHP file
$(’#my_div’).html(‘Downloading…’); // Show “Downloading…” if your external file is large
// Do an ajax request
$.ajax({
url: “externalpage.php?somevariable=”+somevariable
}).done(function(mydata) { // data what is sent back by the php page (mydata is a variable holding output)
$(’#my_div’).html(mydata); // display data
});
[/php]
This is just a sample. You can place it into the code section for a button, have it processed when a drop-down
changes or just about anything…
A note on security: Since Javascript/JQuery/AJAX is client-side code, it is in your browser. This means that
someone can view-source of the page and see this code. Therefore, you should place some security into the
external page to check that the request came from the original page and not an outside page. This would be
a way to protect the code from being hacked. Hope that makes sense!