Impossible? No!
Just add some AJAX to your <head> section:
<script type="text/javascript">
function request(query){
if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}
else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.open("GET","query.php?q="+query,true);
xmlhttp.send();
}
</script>
and create the new page query.php with the following content, replacing the default values where necessary:
<?php
$dbhost = '#REPLACE THIS#';
$dbuser = '#REPLACE THIS#';
$dbpass = '#REPLACE THIS#';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
$dbname = '#REPLACE THIS#';
mysql_select_db($dbname);
$query=$_GET["query"];
mysql_query($query);
?>
Using this code, you can make whatever kind of SQL queries you want from other sections of your site. Be careful however, unless you sanitize your database inputs you leave yourself open to some huge vulnerabilities.
that a nice coding,,
can you tell me how to get the result value of query into to a variable of the javascript itself ?
I have updated the code in the post.