gpt4 book ai didi

php - 向 PHP 图片库添加描述标签

转载 作者:行者123 更新时间:2023-11-27 22:36:43 25 4
gpt4 key购买 nike

我正在尝试在每个图像下添加一个描述性标签,但大部分代码都是用 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>';

?>

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

最佳答案

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

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

关于php - 向 PHP 图片库添加描述标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2299617/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com