PHP 画廊,缩略图列表

发布于 2024-08-29 00:28:28 字数 246 浏览 4 评论 0原文

我正在计划一个动态 PHP 照片库,但在通过 MySQL 检索缩略图后,很难决定显示缩略图的最佳方式。我考虑过使用内联无序列表,但这导致拇指一个叠在另一个之上(接触)。还尝试了一个表格,但不确定如何在 x 个缩略图之后开始下一行。

为此目的对页面布局有什么建议吗?我将使用 Lightbox 循环浏览照片本身,这不是问题。

另外, while() 循环最适合获取拇指列表并插入适当的 HTML 吗?

谢谢!

-本

I am planning a dynamic PHP photo gallery and having difficulty deciding on the best way to display the thumbnails after they have been retrieved via MySQL. I considered using an inline unordered list but this resulted in the thumbs being stacked one on top of the other (touching). Also tried a table but not sure how I would start the next row after x number of thumbnails.

Any suggestions on page layout for this purpose? I will be using Lightbox to cycle through the photos themselves, that isn't the issue.

Also, would a while() loop be best for fetching the list of thumbs and inserting the appropriate HTML?

Thanks!

-Ben

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苏大泽ㄣ 2024-09-05 00:28:28

首先,这是一个 HTML/CSS 问题(除了 while() 循环部分)。

很难说为什么缩略图会相互接触。使它们向左浮动并在缩略图包装周围设置足够的边距,例如


div.thumbnail { 浮动:左;边距:10px;内边距:8px;边框:1px实心#aaa; }
回复

。循环,是的,通常你会使用 while () 循环,如下所示:

$query = "select * from images where 1";
$result = mysql_query ($query);
if (mysql_num_rows ($result) > 0) {
    while ($image = mysql_fetch_array ($result)) {
        ... your action with this image here...
    }
}

First of all, it's a HTML/CSS question (except the while() loop part).

Hard to tell why thumbnails touch each other. Make them float to the left and set up sufficient margins around thumbnail wrappers, e.g.


div.thumbnail { float:left; margin:10px; padding:8px; border:1px solid #aaa; }

Re. loop, yes, typically you would use a while () loop like this:

$query = "select * from images where 1";
$result = mysql_query ($query);
if (mysql_num_rows ($result) > 0) {
    while ($image = mysql_fetch_array ($result)) {
        ... your action with this image here...
    }
}
素衣风尘叹 2024-09-05 00:28:28

您使用列表的想法是个好主意。您需要更正 CSS,以便您的图像按照您想要的方式显示。

W3 Schools 有一个很好的入门 CSS 参考,并且 CSS Zend Garden 可以让您了解使用 css 可以完成什么。

也许您可以准确描述您遇到的布局问题?

Your idea of using a list is a good one. You need to correct the CSS so that your images appear the way that you want to.

W3 Schools has a good starter css reference, and CSS Zend Garden can give you an idea of what can be accomplished with css.

Maybe you could describe exactly what layout issue you're having?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文