大家好,我遇到了使用mysql制作旋转器的麻烦。它向我显示了iframe中的第一个网址,但随后在按钮上不起作用 我在做什么错了,我所需要的只是使用数据库中网址的旋转器,因此它将显示在iframe中,并带有下一个或预览按钮
我尝试的代码
<?php
$sql = "SELECT * FROM list";
$result = mysqli_query($link, $sql);
if( $result )
while($user = mysqli_fetch_assoc($result)) {
?>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
var locations = ["<?php echo $user['Website']; ?>"];
var currentIndex = 0;
var len = locations.length;
$(document).ready(function(){
$(':button').click(function() {
currentIndex = this.value == "Next" ?
currentIndex < len - 1 ? ++currentIndex : 0 :
currentIndex > 0 ? --currentIndex : len - 1;
$('#frame').attr('src', locations[currentIndex]);
});
});
</script>
<?php } ?>
<input type = "button" value = "Previous" /> <input type = "button" value = "Next" />
<br />
<iframe id="frame" src="http://example.com"></iframe>