2013-03-06 66 views
-1

我有一個圖像的文件夾,我希望用PHP加載到圖像列表中,可以使用可排序的jQueryUI功能移動。我跑了一個基本的PHP測試,所以我知道PHP沒有失敗,但是我的代碼可能由於其他原因而錯誤,並且我對jQueryUI的使用經驗不足。以下是我希望使用的代碼的重要部分。尋找一種方式來使用'可排序'功能與PHP

<script type="text/javascript" src="jquery-1.9.1.js"></script> 
<script type="text/javascript" src="jquery-ui-1.10.1.custom.min.js"></script> 
<script language="javascript" type="text/javascript" defer> 

jQuery(document).ready(function($) { 
$("#item-wrap").sortable(); 
$("#item-wrap").disableSelection(); 
}); 
</script> 

<style> 
#item-wrap { list-style-type: none; margin: 0; padding: 0; width: 450px; } 
#item-wrap li { margin: 3px 3px 3px 0; padding: 1px; float: left; width: 300px; 
height: 300px; font-size: 4em; text-align: center; } 
</style> 

<ul id="item-wrap"> 
<?php 
    $imagesDir = '/uploads/gallery1/'; 
    $images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE); 
    $imglist = json_encode($images); 
    for ($i = 1; $i <= count($imglist); $i++) { 
?><li><?php 
echo $array[$i]; 
?></li><?php 
    } 
</ul> 
?> 

圖像無法顯示,也沒有創建列表。 任何幫助或建議,非常感謝。

+0

歡迎計算器。你會詳細說明什麼是真正的失敗? – 2013-03-06 12:39:49

+0

你真的有/ uploads/gallery1 /文件夾嗎?或者你的意思是相對路徑,「uploads/gallery1 /」? – Stormherz 2013-03-06 12:41:00

+0

不加載圖像,並且不生成列表。爲了迴應Stormherz,這條道路是相對的。 – user2126833 2013-03-06 13:22:22

回答

0

嘗試用

<?php 
    $imagesDir = dirname(__FILE__) . '/uploads/gallery1/'; 
    $images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE); 
    for ($i = 0; $i < count($images); $i++) { 
?><li><?php 
    echo $images[$i]; 
?></li><?php 

更換你的PHP代碼塊並請準確指定的問題是什麼 - 如果它是一個錯誤 - 請附上該消息的問題

+0

圖像無法顯示,也沒有列出。 – user2126833 2013-03-06 13:28:18

+0

@ user2126833使用var_dump($ images)檢查$圖像;如果是填寫正確的名稱 – Stormherz 2013-03-06 13:29:39

+0

var_dump($ images)返回空 – user2126833 2013-03-06 13:36:14

相關問題