当点击下一个按钮旋转木马时从数据库加载项目
答
我认为你需要使用PHP,SQL,jQuery的(AJAX)
PHP:
//This will output using JSON
header('Content-type: application/json');
$getDBData = mysql_query("SELECT * FROM table");
while($rows = mysql_fetch_array($getDBData)){
$id = $rows['id'] //ID from the DB;
$name = $rows['name'] //Name from the DB too;
$JSONfeedback = array(
"id" => "$id",
"name" => "$name"
);
echo json_encode($JSONfeedback);
}
JS:
$.post('thatPHP.php',function(feedback){
console.log('This is my id: ' + feedback.id);
console.log('This is my name: ' + feedback.name);
});
+0
非常感谢你我会试试这个:) – Nupur
关键字来这里搜索的是'ajax'。熟悉这个概念,然后使用jQuery'ajax()'或'post()'函数。 – user3154108
非常感谢你,我会尝试与Ajax。 – Nupur