Forum Moderators: open

Message Too Old, No Replies

run sql in javascript

         

n_amalyna

6:14 am on Jul 23, 2007 (gmt 0)

10+ Year Member



hai,

i'm new here. i'm wondering.. can we put sql query in a javascript code? for example: <javascript> onchange () ... Select * from menu ....</javascript>

thank you!

eelixduppy

8:03 am on Jul 23, 2007 (gmt 0)



Welcome to WebmasterWorld!

Actually, javascript cannot communicate directly with MySQL - so no. However, you can use Javascript to communicate with the server in the background, then use server-side scripting such as Perl or PHP to run database queries and send the information back to the browser (javascript in this case) in XML format. This is commonly known as AJAX.

Some places you may want to start looking:
Rasmus' 30 second AJAX Tutorial [news.php.net]
The HttpRequest Object [w3schools.com]

good luck

Bernard Marx

10:26 am on Jul 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



then use server-side scripting such as Perl or PHP

..or JScript.

- This is a Javascript forum after all.