我需要轮播,只有当点击下一个按钮而不是页面加载时才从DB加载项目。 请帮忙, 提前致谢
答案 0 :(得分:0)
我认为你需要使用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);
});