php - 从数据库中获取数据后如何在div中滑动

标签 php jquery html mysql

我试图找到如何在从数据库中获取数据后滑动数据 block 。 我尝试了很多但没有得到结果。请帮助我找出解决方案 这是我的代码

<html>
<head>

</head>
<body>
<?php 
$servername="localhost";
$username="root";
$password="";
$db="lalcoresidency";

$conn=mysqli_connect($servername,$username,$password,$db);

if(!$conn){
    die("connection failed:".mysqli_connect_error());
}
?>
<div class="flexslider">
<ul class="slides">
<?php
$query="select * from testimonial order by r_id desc";
$result = mysqli_query($conn, $query);

while($row=mysqli_fetch_array($result)){
    ?>
    <li>
    <?php echo $row['review'];?>
    </li>
<?php
    }
?>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
    $('.flexslider').carousel({
      interval: 3200
    });
  });
</script>
</body>

这已经花了我很多时间,但我没有得到解决方案。此代码仅逐行显示数据

my code output
"Loving Staff Welcoming and helpful... Kind and welcome the food is great. Breakfast included."
"Total value for money."
"Excellent facilities with good location and very co-operative and efficient staff."
"Accommodation worth the money paid for... Staff were very helpful and in-house car hire rates were so reasonable."
"An excellent stay... Loved the stay and definitely look forward to keep going back for our next stay."

它一个一个地显示数据。但我想显示第一行数据,然后在滑动后需要显示第二行。然后在滑动第三行之后。 请帮我找到解决方案

最佳答案

那是因为 .carousel 没有在 jQuery 中定义。

这是一个 jQuery 插件,您可以从他们的网站下载。

https://plugins.jquery.com/jcarousel/

另外别忘了关闭<div><ul>标签。

关于php - 从数据库中获取数据后如何在div中滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37208271/

相关文章:

php - 如何检查用户是否已存在于 SQL 数据库中?

jquery - 使用jquery获取解析的html结果集中元素的索引

css - 如何根据特定尺寸调整视频?

html - 我的网页是 2 列,但在放大时重叠成 1 列?

java - PHP SoapClient : Object passed is received as NULL in Java

php - 需要通过 PHP 压缩 CSS 和 JavaScript,但需要了解性能影响以及如何实现?

javascript - 滚动js滚动条

html - 在以下场景中,如何在 Bootstrap 框架中并排设置图标图像和文本标题?

php - 在 mysql/PHP 中执行存储过程时出现错误 "Commands out of sync, you can' t 立即运行命令

javascript - ajax调用后无法调用jquery