Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Very simple auto gallery script, photos.php:</p> <pre><code>&lt;?php function getDirTree($dir,$p=true) { $d = dir($dir);$x=array(); while (false !== ($r = $d-&gt;read())) { if($r!="."&amp;&amp;$r!=".."&amp;&amp;(($p==false&amp;&amp;is_dir($dir.$r))||$p==true)) { $x[$r] = (is_dir($dir.$r)?array():(is_file($dir.$r)?true:false)); } } foreach ($x as $key =&gt; $value) { if (is_dir($dir.$key."/")) { $x[$key] = getDirTree($dir.$key."/",$p); } } ksort($x); return $x; } $tree = getDirTree("./foto/"); echo '&lt;div id="gallery"&gt;'; echo '&lt;ul class="linone"&gt;'; foreach($tree as $element =&gt; $eval) { if (is_array($eval)) { echo '&lt;li&gt;&lt;h4&gt;'.$element.'&lt;/h4&gt;'; echo '&lt;ul class="linone photos"&gt;'; foreach($eval as $file =&gt; $value) { if (strstr($file, "jpg")) { $file = 'foto/'.$element.'/'.$file; echo '&lt;li&gt;&lt;a href="'.$file.'"&gt;&lt;img src="'.$thumb.'" alt="'.$thumb.'"/&gt;&lt;/a&gt;&lt;/li&gt;'; } } echo '&lt;/ul&gt;'; echo '&lt;/li&gt;'; } } echo '&lt;/ul&gt;'; echo '&lt;/div&gt;'; </code></pre> <p>Also I use the lightbox jQuery plugin to make this gallery comfortable to view.</p> <p>And also managing photos for this page is very-very simple - you just need to upload .jpg files to your photos directory ('/foto/', for this example).</p> <p>index.php:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;My Gallery&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php require_once('photos.php') ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This file will include photos.php file and runs it, output of photos.php script will come between tags.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload