0

Im new to web programming, so sorry if the concepts are too basic. Im trying to write data passed from a web page to a local database with php. Im thinking using mySQL. Is it possible? If so, is it enough to download mySQL Workbench?

Thanks in advance.

user3279394
  • 141
  • 7
  • *"Or is it a better idea to store information to a local database with php?"* I guess that depends on the data and the app. JavaScript cannot access the local file system. Please provide information about what you are really trying to do and what you have found out so far. – Felix Kling Jun 17 '15 at 04:56
  • Actually Im trying to save a table so I thought storing in a database might be easier. I found out that javascript doesnt allow writing to a local file but with jquery it might be possible with the TiddlySaver but I couldnt manage to do it. – user3279394 Jun 17 '15 at 05:08
  • jQuery is just a library written in JavaScript. By that definition it can't do any more than the language itself. – Felix Kling Jun 17 '15 at 05:11
  • So it is not possible with jquery? What about php? Can I use it to access a local database? – user3279394 Jun 17 '15 at 05:12

2 Answers2

2

JavaScript, in general, does not have permission to write to files on the client's machine.

How to read and write into file using JavaScript

Community
  • 1
  • 1
Verox
  • 360
  • 1
  • 12
2

Like Verox said Javascript does not allow you to write to a file.

Having said that you can probably save it as an object and give a download link for a new file like below if your use case allows that.

var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(obj, null, 2)); $('<a id="downloadLink" href="data:' + data + '" download="data.json">download file</a>')

Saving to database on local purely rests on your use case.