从DB加载项目时,单击下一个按钮旋转木马


Load item from DB when clicking on next button carousel

我需要carousel加载项目从DB只有当点击下一个按钮,而不是当页面加载。请帮忙,提前感谢

我认为你需要使用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);
});