I have been looking at this code and can't see the errors.
I would like as a test for myself to post a SQL query to a PHP file and do the query and return the selected rows. So what is wrong with this POST, and how do I pickup the query on the PHP side. Right now I don't receive a value looking at $_POST.
$(document).ready(function () {
$("button[name='History']").click(function () {
var btnHistory = ("In Click function!");
console.log(btnHistory);
queryStr = "SELECT * FROM time_table WHERE" +
" EXTRACT(MONTH FROM DATE_FIELD ) = DATE_FORMAT(NOW()," +
" '%c') AND EXTRACT(DAY FROM DATE_FIELD ) = DATE_FORMAT(NOW(), '%e')" +
" ORDER BY DATE_FIELD";
$.ajax({
type: "POST",
contentType: "text/plain",
url: "showDatabase02.php",
data: queryStr,
success: function (data) {
console.log("returned data = " + data);
}
});
return false;
});
});
In the php file:
$query = $_POST[0];