I'm now starting to deal with web development in PHP. We know that to have an efficient and dynamic system, it is advisable to use 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 "get" the data in the database and generate a graph, using for example the Google Charts API. The first thing I thought of 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 it in Javascript. However, this would not be a good programming practice, as my code would be unreadable to handle 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 and JavaScript programming, as well as other languages with JavaScript.