View Full Version : How to use Mysql Query inside Javascript functions?

05-29-2006, 03:23 PM
Hello Everybdy,

I am trying to use Mysql Query inside a Javascript function, which also has php code. I am trying to use the on-click property of <a></a> tag, so as to call a javascript function, which is having an argument and this argument is being used by Mysql Query to check whether the table is empty, for that specific record.

If anybdy knows, whats the solution, please tell me!!!
Thanks in advance.

05-29-2006, 04:24 PM
mysql is database stuff, hence, server side. javascript is ONLY client side scripting. You may not interact with the server in any way (directly). However, You could use AJAX calls to like a php file that will return if the table is empty or not. But all in all, you can't use javascript itself to interface with mysql

Single Paradox
05-29-2006, 07:33 PM
There is no way to do this outside of Ajax, of course you can always echo something in. Such as:


function doalert(){
alert('<?php echo($var) ?>');

05-30-2006, 08:08 AM
Thanks for the replies, I too searched an answer, but everywhere I got the same answer that I need AJAX. Thanx again, this forum is very helpful.:thumbsup: