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 に答える