Javascript for MySQL

How do I use mysql commands in javascript language and auto appear them
in my html layout? I already know some basic javascript commands but I
am trying to incorporate sql commands but it won’t work. Is there a way
to do it?

Here is the basic concept.

If you are using php as server side.
You can fetch first the data using php and mysql.
and store the value into json and convert it to javascript (ajax)

Hi silhouettezero1993 welcome to the forum

Please explain in what context you’re wanting to do this.

As solidcodes posted, the typical use case is to have JavaScript send various values to a server script.
The server script use the values to run a query.
The server sends the results back to the JavaScript.
The JavaScript uses the returned information to modify the page in the browser.

AFAIK there is no way that JavaScript can directly access a server database.

There are ways to have JavaScript use localStorage eg. SQLite,
But it can be complicated since the script needs “permission” to use the users computer

okay, so I have to stick with PHP, thank you very much solidcodes.

Okay, thank you, Mittineague.

unless you run the JavaScript on the server, like in Node.js. But that’s not the same JavaScript as the one in the browser.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.