termanater13 Posted April 28, 2007 Share Posted April 28, 2007 I have XAMPP on my computer and I want to edit the index file to show all the folders in the local host directory, so I could surf all the web pages I have saved in the local host folder, and I do not want to do anything with MySql with this.I'm asking since I can only find a reference page, Im not asking for people to make the code for me, I just want help so I can mek it my self. Link to comment Share on other sites More sharing options...
msd Posted April 28, 2007 Share Posted April 28, 2007 http://www.php.net/readdir Link to comment Share on other sites More sharing options...
termanater13 Posted April 28, 2007 Author Share Posted April 28, 2007 http://www.php.net/readdirthanks, I figured out what I need to edit in it to get what I want done, thanks for the helpthe code below is edited code from the site msd gave and im getting a "Parse error: syntax error, unexpected T_ELSEIF in C:\Program Files\xampplite\htdocs\test.php on line 15"<?phpecho '<html>';echo '<head>';echo '<title>Local Host DIR</title>';echo '</head>';echo '<body>';echo '<table align="center" width="50%">';if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<tr>"; echo "<td align=\"center\">" . "<a href=\"$file\">$file</a>" . "</td>" . "\n"; if(is_dir($file)) { echo "<td align=\"center\">directory</td>"; elseif (is_executable($file)) echo "<td align=\"center\">executable</td>"; elseif (is_file($file)) echo "<td align=\"center\">regular file</td>"; else echo "<td align=\"center\">unknown to PHP</td>"; } echo "</tr>"; } } closedir($handle);}echo '</tr>';echo '</table>';echo '</body>';echo '<html>';?> Link to comment Share on other sites More sharing options...
msd Posted April 28, 2007 Share Posted April 28, 2007 IF goes like this: if (condition) { do something}elseif (other condition){ do something else}else { do something else 2} You problem is here: if(is_dir($file)) {echo "<td align=\"center\">directory</td>";elseif (is_executable($file)) You wrote: if (condition){ elseif {do something}. WRONG.Delete { from line 15 and } from line 21. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.