0

I want to store data into mysql table using JavaScript. But, I don't want to use php. Is it possible?

Touheed Khan
  • 2,149
  • 16
  • 26
Jahangir
  • 11
  • 2

3 Answers3

1

Javascript is a client-side language, so it runs on the clients browser. If you still want to insert into mysql using javascript then you could use something like node.js which would run on the server-side.

For instance this is how an insert using node.js would look like:

var post  = {id: 1, title: 'Hello MySQL'};
var query = connection.query('INSERT INTO posts SET ?', post, function(err, result) {
    // check result or error!
});
lloiacono
  • 4,714
  • 2
  • 30
  • 46
  • actually I want to use it only for like counter, I mean i want to increment in like counter. I hope you might understand what I want to do .. further is it a good approach to use node.js for only like counter ? – Jahangir May 03 '17 at 09:56
  • @Jahangir what is it that you would like to count? – lloiacono May 03 '17 at 10:05
  • as I said above. I want to count "likes" of a video on my webpage. – Jahangir May 03 '17 at 10:28
0

You may need to consider Node Js for such job. Check this

0

Jahangir jan, It's not possible to use client side Javascript to store something into the MySQL. But it's possible to use server side Javascript to do it.

Hossein
  • 2,592
  • 4
  • 23
  • 39