5
I am now beginning to deal with web development in PHP. We know that to have an efficient and dynamic system, we recommend using Javascript, such as, Jquery, Angularjs, Backbone.js and others. But from what I know of Javascipt, it does not have an API to connect to the database.
I have a system to develop in PHP to manipulate data from the database. In this case I need to "take" the data in the database and generate a chart, using for example the Google Charts API. The first thing I thought, is to manipulate Javascript code with PHP, ie, put the tags Javascript inside the PHP code (code to connect to the database) and get the data and insert into Javascript. However, this would not be a good programming practice, because my code would be unreadable to manipulate and I would have future problems with my system.
I would like to get experienced programmers on how to get around this situation. Basically, how can I manipulate data from the database in Javascript, Angularjs, Google Charts and etc. and how can I get a good integration between PHP programming and Javascript, as well as other languages with Javascript.
Since you have Angularjs and Backbonejs, I advise you to create a REST service in PHP return a JSON, then call your API/Service using AJAX to then create your chart.
– Tobias Mesquita
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero