0

我正在尝试在每张图片下添加一个描述性标签,但大部分代码都是用 PHP 编写的,我不熟悉如何在不搞砸整个结构的情况下对其进行编程。这是网站:http ://suncoastdeck.com/index.php?page=portfolio&start=0

这是投资组合页面的代码:

<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>';

  ?>

我几乎想要的是让部分下拉更多,我可以在其中添加有关图片的其他信息。有什么建议么?

4

1 回答 1

1

您需要一个数据库,否则您可以将您的描述存储在图像旁边的文本文件中。你试过什么了?

基本上,您需要创建一个接受图像名称和标题的表单,获取标题并将其写入文件或数据库。然后在显示标题时,您只需添加一个<div>从文件中读取的file_get_contents(). 为什么不将脚本复制到另一个目录并开始试验呢?人们可能不会为你写完整的东西;)

于 2010-02-19T21:33:40.997 回答