Thread: PHP Issues.
View Single Post
Old 09-05-2009, 22:18   #4
Druchii
cf.mega poster
 
Druchii's Avatar
 
Join Date: Mar 2006
Location: Oslo, Norway.
Age: 37
Services: Canal Digital: 50/10
Posts: 7,577
Druchii has a nice shiny star
Druchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny star
Re: PHP Issues.

Fully functional (abeit badly written) code:
Code:
<?php
$i = 0;
$Folder = "./Photos/";
$DirHandle = @opendir($Folder) or die($Folder." could not be opened.");
print ("<table width=40% align=center valign=center>");
while ($Filename = readdir($DirHandle))
{
if ($i == 2) print ("<tr>");
if (($Filename != ".") AND ($Filename != "..")) print ("<td width=200 height=200><img src=\"$Folder$Filename\" height=95% width=95%>$i</img></td>");
if ($i == 2) print ("<//\tr>");
if (($Filename != ".") AND ($Filename != "..")) ++$i;;
}
closedir($DirHandle);
print ("</table>");
?>
Cheers for the pointers

---------- Post added at 00:18 ---------- Previous post was at 00:15 ----------

Quote:
Originally Posted by punky View Post
Also, another prob I spotted... your <tr> closing tag should be </tr> not <\tr>.

A backslash within a string is a special character. In this case \t = tab.
That causes a problem, it seems to then spit out a </tr> tag every iteration, rather then when it should be (every 2nd).

EDIT:
Also changed the closing TR tag code to:
Code:
if ($i == 4) print ("<//\tr>") AND $i = 0;
(And modified the opening tags, it now is every 4 rather than just the first 4)
Druchii is offline   Reply With Quote