简体   繁体   中英

PHP gallery, thumbnail listing

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

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?

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, eg

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...
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM