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