0
我想我一起拼命的脚本有困难。我可以打印文件夹中的内容的文件名,没问题。当img网址被列入div中时,我有幻灯片显示工作。现在我需要获取文件名,并以某种方式回应....PHP:使用opendir填充JS幻灯片
<script type="text/javascript">
function slideSwitch() {
var $active = $('#slideshow DIV.active');
if ($active.length == 0) $active = $('#slideshow DIV:last');
// use this to pull the divs in the order they appear in the markup
var $next = $active.next().length ? $active.next()
: $('#slideshow DIV:first');
// uncomment below to pull the divs randomly
// var $sibs = $active.siblings();
// var rndNum = Math.floor(Math.random() * $sibs.length);
// var $next = $($sibs[ rndNum ]);
$active.addClass('last-active');
$next.css({opacity: 0.0})
.addClass('active')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval("slideSwitch()", 5000);
});
</script>
<div id="slideshow">
<?php
$dir = "images/featured/";
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
echo "";
}
closedir($dh);
?>
</div>
我真的很感谢你的建议。所有这一切,什么是自学PHP的最佳方式?我的问题是,我没有学习的奢侈:A,B,C,D ......我不得不直接跳起来解决我们商业目前需要的东西。 (所以我知道PHP w/MySQL!)现在我真的很想学习'正确'的方式。我已经完成了W3学校教程以及其他课程,但是我想要一个更加结构化的课程。 – Commandrea
首先,我会聘请一个知道他们在做什么的人,因为网页/应用程序不正确可能会损害您的业务收入/机会损失的底线,而不是聘用专业人士。尽管如此,这不应该阻止你改善自己。只要坚持PHP或JS(每个都是自己的),直到你在试图将它们结合到一个页面中之前都能够很好地完成。如果你有足够的信心,就开始尝试做你自己的脚本(不是来自教程)。从小开始,增加复杂性,你会得到更好。 –
幸运的是,我不必使用这种方法来显示'幻灯片'。我只是认为能够从php目录动态填充它会节省时间。现在,随着时间的推移,这段时间至少需要六个月的时间才能真正得到拯救。我扔了毛巾 - 并且在结婚前更好地了解PHP和JS。就像现实生活:)再次感谢你。 – Commandrea