Jump to content

Forcing a line break after 5 images have been displayed??


Recommended Posts

Hello everyone,

 

How can I force a line break after 5 images have been displayed within this code?

 

<?php

	//  OPEN THUMBNAILS DIRECTORY
        $handle = opendir ('./thumbnails/');
        while (false !== ($file = readdir($handle))) {
		//  RECOGNISE FILES
            if($file != "." && $file != ".." && $file != basename(__FILE__)) {

			//  PRINT THUMBNAIL IMAGE AND LINK TO EACH LARGER IMAGE FOR EVERY IMAGE FOUND
			print "<a href='./uploadedimages/{$file}' target='_blank'> <img src='./thumbnails/{$file}'></a>";


            }
        }
?>

 

Thanks alot, Luke

Like this:

 

<?php

	//  OPEN THUMBNAILS DIRECTORY
        $handle = opendir ('./thumbnails/');
        $count = 0;
        while (false !== ($file = readdir($handle))) {
		//  RECOGNISE FILES
            if($file != "." && $file != ".." && $file != basename(__FILE__)) {

			//  PRINT THUMBNAIL IMAGE AND LINK TO EACH LARGER IMAGE FOR EVERY IMAGE FOUND
			print "<a href='./uploadedimages/{$file}' target='_blank'> <img src='./thumbnails/{$file}'></a>";

            if ($count == 5){
               echo '<br />';
               $count = 0;
            }

			$count++;
            }
        }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.