projecttool8 Posted February 21, 2015 Share Posted February 21, 2015 So, I currently have a script (in beta mode, only works when the sun shines), that can upload an image and store directly in a mysql database (using the BLOB data type); the script is also able to retrieve the BLOB data and display them vertically on the page; I actually need to dsiplay them horizontally across the page instead. So currently the retrieved images are printed in this format: 1 2 3 4 5 6 7 8 and I need it to print this way: 1 2 3 4 5 6 7 8 sounds like a for loop somewhere... any takers on how to implement the feature? Quote Link to comment https://forums.phpfreaks.com/topic/294786-displaying-blob-images-horizontally-from-mysql/ Share on other sites More sharing options...
scootstah Posted February 21, 2015 Share Posted February 21, 2015 You could actually just use CSS styling to achieve this. Give the images display: inline-block; and they will tile horizontally until they get to the edge of the parent container, then drop down and continue on. Example: http://jsfiddle.net/fzbe4jpm/ To achieve it with a for loop, you can use the modulus operator to decide when to insert a line break. $i = 1; foreach ($images as $image) { if ($i % 4 === 0) { echo '<br />'; } echo '<img src="' . $image . '" />'; $i++; }Something like that. Quote Link to comment https://forums.phpfreaks.com/topic/294786-displaying-blob-images-horizontally-from-mysql/#findComment-1506364 Share on other sites More sharing options...
mac_gyver Posted February 21, 2015 Share Posted February 21, 2015 see the following link - http://forums.phpfreaks.com/topic/11572-multi-column-results/ Quote Link to comment https://forums.phpfreaks.com/topic/294786-displaying-blob-images-horizontally-from-mysql/#findComment-1506365 Share on other sites More sharing options...
projecttool8 Posted February 22, 2015 Author Share Posted February 22, 2015 You could actually just use CSS styling to achieve this. Give the images display: inline-block; and they will tile horizontally until they get to the edge of the parent container, then drop down and continue on. Example: http://jsfiddle.net/fzbe4jpm/ To achieve it with a for loop, you can use the modulus operator to decide when to insert a line break. $i = 1; foreach ($images as $image) { if ($i % 4 === 0) { echo '<br />'; } echo '<img src="' . $image . '" />'; $i++; }Something like that. Thank you for the tip. A for loop did actually work... This prints the result/format that was required: <html> <body> <table border="1"><tr> <?php for ($number = 1; $number <= 8; $number++) { if ($number % 4 === 1){ echo '</tr>'; } echo '<td>'.$number.'</td>'; } ?> </tr></table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/294786-displaying-blob-images-horizontally-from-mysql/#findComment-1506438 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.