Without more details about what kind of remote database or data you are trying to use it is hard to propose a solution.
In general for remote databases I like to use Parse.com APIs and find them very responsive.
Parse.initialize("YOUR KEY GOES HERE"); //API key
//whatever you want to call your storage object
var jobApplicant = Parse.Object.extend("JobApplicant");
//create new instance of your Parse Object
var jobApplicant = new JobApplicant();
//you can add each param separately and save
jobApplicant.set("jobid", "1234");
jobApplicant.set("name", "john smith");
jobApplicant.set("position", "manager");
jobApplicant.set("years experience", "5");
jobApplicant.set("status", "rejected");
jobApplicant.save();
//or use object literal notation
jobApplicant.save({jobid: "1236", name: "ashley jones",
position: "software engineer",
years experience: "15",
status: "accepted offer"
}).then(function(object) {
alert("Job Applicant Recorded!");
});
//query
var NewHire = Parse.Object.extend("NewHire");
var query = new Parse.Query(NewHire);
query.equalTo("status", "accepted offer");
query.find({
success: function(results) {
alert("Successfully retrieved " + results.length + " candidates.");
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
var object = results[i];
alert(object.id + ' - ' + object.get('name'));
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
For more information please see: https://parse.com/docs/js_guide#queries
If you are set on using php, you could echo the javascript inside php. I'm sure this isn't the most idea way to use php, however it should work.
<?php
echo "
<script type=\"text/javascript\">
//place javascript here
</script>
"
?>