Php Code To Javascript
Solution 1:
You shouldn't ever have a direct javascript <-> database connection.
What you would use is a intermediate step,
For reading, a php script that gets data from DB then generates a 'json' stream for the javascript to read.
Or posting the results of a form to a php script that actually inserts it into the database.
Solution 2:
I don't know if there are any javascript DB connectors.
Even if there are db connectors you wouldn't want to connect directly from the user with his javascript to your database. This would be a great security hole.
Solution 3:
Assuming you are not using server-side Javascript (node.js) then what I think you want to do is to stick with your PHP code on the server but call that from JS (in the browser), rather than trying to recreate it. You can't access your server-side database directly from JS running in a browser.
If you have, for example, a webpage called getcurrency.php that contains the code you pasted above then you can use AJAX to call this URL from JS whenever you like. The jQuery JS framework would make this easy for you: http://api.jquery.com/jQuery.ajax/
Post a Comment for "Php Code To Javascript"