ehhhm maybe you should read something about writing backends... creating apis and so on..
it is the easiest step to connect a dbs with a script language.
and it would be not that good if you read out your backend files .
the php-file contains your backend logic (reading and setting data, processing data).
easiest way to send response is to use the "echo" command in php --> keep in mind that you need to convert your response content to json ,
If this all is unclear.. please read tutorials about backend-programming-technologies and so on.