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 thu开发者_StackOverflow社区mbs and inserting the appropriate HTML?
Thanks!
-Ben
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... } }
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?
精彩评论