Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to create an HTML table form directory listing...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi there,

I've built this page that is supposed to parse through the images directory and build an HTML table that is 4 columns wide and as long as it needs to be to get all of the images. All of the code seems to work except that it keeps repeating the same file.

BTW: This code only displays the filename in the cell so far, since I'm just trying to get the table building portion right.

Can anyone tell me why it won't advance to the next file?
Code:
<table>
<?
$thumbstr  = &quot;tn_&quot;;
$jpgext    = &quot;.jpg&quot;;
$startnum  = 1;
$endnum    = 4;
$handle    = opendir(&quot;images/Skye&quot;);

while (false!==($file = readdir($handle))) 
{ 
    while ($file != &quot;.&quot; && $file != &quot;..&quot; && strstr($file, $jpgext)) 
    { 
    print(&quot;<tr>\n&quot;);
        for ($colctr = $startnum; $colctr <= $endnum; $colctr++)
        {
            switch($colctr)
            {
	      case 4:
	        print(&quot;<td>$file</td></tr>\n&quot;);
                $colctr = $startnum;
		break;
              default:
		print(&quot;<td>$file</td>\n&quot;);
                break;
            }
        }
    } 
}
closedir($handle); 
print(&quot;</table>&quot;);
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top