0
我的問題是如何獲得的數據庫信息(在我的情況下點只是一個數字)從PHP文件,所以在這裏jQuery的AJAX腳本是我的jquery:如何從php文件得到jQuery的功能信息
function rate_down(id) {
var id = id;
//submit data to php script
var data = {
"id": id,
};
$.ajax({
type: "POST",
url: "rating.php",
data: data,
success: function(response) {
var currentValue = /* here i want to put the db number */
var newValue = +currentValue - 1;
$("#points_"+id).text(newValue);
},
error: function(jqXHR, textStatus, errorThrown){
alert(errorThrown);
}
});
};
而我想要我的raiting.php。我不知道我是否應該發佈它,因爲它的無用的,但這裏是我的MySQL查詢在raiting.php:
$pic_id = (int) $_REQUEST['id'];
mysql_query = mysql_query"SELECT points FROM `photos` WHERE `id` = '$pic_id'";
安全注意:在使用MySQL查詢一樣,很容易出現SQL注入。在您的系統的生產環境中非常沮喪;) –