andreasb Posted March 5, 2010 Share Posted March 5, 2010 Hello, I'm creating a website where I want there to be 5 images per row (with several rows) with some text below each image. The image path and description is fetched from a MySQL database. Now, which should I chose; DIV or Tables when it comes to making horizontal rows of images from MySQL? I've tried using tables in the mysql_fetch_array, but the results are only 1 image per row with the description below it, so it doesn't make a horizontal line of images and descriptions. Please help me out ! Quote Link to comment https://forums.phpfreaks.com/topic/194289-div-or-table-for-mysql-output/ Share on other sites More sharing options...
bPHP Posted March 5, 2010 Share Posted March 5, 2010 I would use divs, thats how I usually do it. Quote Link to comment https://forums.phpfreaks.com/topic/194289-div-or-table-for-mysql-output/#findComment-1022108 Share on other sites More sharing options...
andreasb Posted March 5, 2010 Author Share Posted March 5, 2010 OK, thank you. Is there an easy way to make it a maximum of 5 images per row? Should I just use CSS width or something ? Quote Link to comment https://forums.phpfreaks.com/topic/194289-div-or-table-for-mysql-output/#findComment-1022109 Share on other sites More sharing options...
zeodragonzord Posted March 5, 2010 Share Posted March 5, 2010 I would go with DIVs but if it's mean to be tabular data, even as images, then tables aren't so bad. DIVs will give the most flexibility though. Have your PHP wrap around a new DIV after five images. Use modulous (%5) and if it returns 5, then create a new DIV section. Quote Link to comment https://forums.phpfreaks.com/topic/194289-div-or-table-for-mysql-output/#findComment-1022110 Share on other sites More sharing options...
andreasb Posted March 5, 2010 Author Share Posted March 5, 2010 This is pretty much what I want, just using 5 per row instead of 3 like in the image: Quote Link to comment https://forums.phpfreaks.com/topic/194289-div-or-table-for-mysql-output/#findComment-1022115 Share on other sites More sharing options...
zeodragonzord Posted March 5, 2010 Share Posted March 5, 2010 Since there's no natural way to do captions, you can wrap DIVs around each element to apply the text underneath the image. <div class="box"> <img src="pony.jpeg"> <div class="caption">This is my pony</div> </div> Then put five of those in a single DIV for each row. You'll have to add some styles to make it the way you want but this will give you an idea. Quote Link to comment https://forums.phpfreaks.com/topic/194289-div-or-table-for-mysql-output/#findComment-1022163 Share on other sites More sharing options...
bPHP Posted March 6, 2010 Share Posted March 6, 2010 Yes, use the CSS to style the divs to the desired widths, heights, positions, etc. What I usually do is have wrapper divs, for example <div class="picturesWrapper">, then inside have <div class="pictureRow"> and <div class="caption"> You can then easily change options from the CSS by modifying each class. I find this way of working to be very flexible when there is need for changes. Quote Link to comment https://forums.phpfreaks.com/topic/194289-div-or-table-for-mysql-output/#findComment-1022230 Share on other sites More sharing options...
andreasb Posted March 6, 2010 Author Share Posted March 6, 2010 Thanks a bunch, guys ! Quote Link to comment https://forums.phpfreaks.com/topic/194289-div-or-table-for-mysql-output/#findComment-1022239 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.