2010-02-19 86 views
0

我想在每個圖像下添加一個描述性標籤,但大部分代碼都在PHP中,我不會熟悉如何編程它而不會搞砸整個結構。這裏是網站:http://suncoastdeck.com/index.php?page=portfolio&start=0將描述標籤添加到PHP圖像庫

這裏是投資組合頁面代碼:

<div class="content-box"> 

<? 

    //total number of images 
    $total = 77; 

    //max number of thumbnails per page 
    $max = 9; 

    //what image do we want to start from? 
    $startcount = $_GET["start"]; 

    //if there is not a defined starting image, we start with the first 
    if(empty($startcount)) 
    { 
    $startcount = 0; 
    } 

    //start off the loop at 1 
    $loop = 1; 


    //start the loop 
    while($loop <= $max) 
    { 

    //for the picture labels 
    $num = $startcount + $loop; 

    if($num > $total) 
    { 
    $num = $num - 1; 
    break; 
    } 

    // Add class="last" to every third list item 
    if(is_int($num/3)) 
    { 
    $last = ' class="last"'; 
    } 
    else 
    { 
    $last = ""; 
    } 

    //the code for the image 
    echo ' 

    <li'.$last.'><a href="images/portfolio/pic-'.$num.'.jpg" rel="milkbox[gall1]"><img src="images/portfolio/thumbs/pic-'.$num.'-thumb.jpg" width="256" height="138" alt="Thumbnail of image '.$num.'" /></a><div>'.$num.'</div></li>'; 


    //add 1 to the loop 
    $loop++; 
    } 

    echo '</ul>'; 

    //Calculate the number of pages 
    $total_pages = $total/$max; 

    //clean it up 
    if(!is_int($total_pages)) 
    { 
    $total_pages = floor($total_pages) + 1; 
    } 

    //start the page count at 1 
    $ploop = 1; 

    echo '<hr /><div id="portfolio-wrap"><div id="pages">Page: '; 

    while($ploop <= $total_pages) 
    { 
    $offset = ($ploop * $max) - $max; 

    if($startcount == $offset) 
    { 
    echo '<span>'.$ploop.'</span>'; 
    } 
    else 
    { 
    echo '<a href="index.php?page=portfolio&start='.$offset.'">'.$ploop.'</a>'; 
    } 
    $ploop++; 
    } 

    echo '</div>'; 


    echo '<div id="portfolio-foot-left"><p>Displaying Images <strong>'.($startcount + 1).' - '.$num.'</strong> of <strong>'.$total.'</strong></p></div></div>'; 

    ?> 

差不多我想要的是讓部分降下來一點更多的地方我可以添加有關圖片的其他信息。有什麼建議麼?

回答

1

您需要一個數據庫,否則您可以將描述存儲在圖像旁邊的文本文件中。你試過什麼了?

基本上你需要創建一個接受圖像名稱和標題的表單,獲取標題並將其寫入文件或數據庫。然後當顯示標題時,您只需添加一個<div>,該文件從file_get_contents()的文件中讀取。爲什麼不將腳本複製到另一個目錄並開始試驗?人們可能不會寫你整個事情;)

+0

我知道創建一個image_gallery_description.txt文件具有所有的具體描述,但調用特定的.txt的代碼有多廣泛? – Blaze 2010-02-19 21:39:15