Dirs Listing

Started on the old forum in December 2007 · view the original in the archive · old links redirect here

5 replies · 469 views · started 18 years ago · 1 min read

2 participants
Guest #1

Can any 1 write list script? I need glob all dirs(in folder onli dirs) from folder and add to list like this

if($page=="" || $page<=0)$page=1;
$num_items = $all;//changable
$items_per_page= 5;
$num_pages = ceil($num_items/$items_per_page);
if(($page>$num_pages)&&$page!=1)$page= $num_pages;
$limit_start = ($page-1)*$items_per_page;
	 if($page>1)
{
  $ppage = $page-1;
  echo "<a href=\"index.php?page=$ppage\">«Back</a> ";
}
if($page<$num_pages)
{
  $npage = $page+1;
  echo "<a href=\"index.php?page=$npage\">Next»</a>";
}
echo "

$page/$num_pages ";

wizard Senior · 493 posts #2

HERE'S MY BADASS LIST SCRIPT

    public function list_navigation($num_pages, $p, $link )
    {
        $Body = new Body;        

                if($num_pages > 1) {
                    $Body->do_br();
                    if($p > 1 )
                    {
                        $pg = $p - 1;
                        $Body->add_link("".$link."&p=$pg","«",'normal');
                        $Body->add_text(" | ");
                    }else{
                        $Body->add_text("«");
                        $Body->add_text(" | ");
                    }
                
                    for ($i = 1; $i <= $num_pages; $i++)
                    {
                        if($p == $i)
                        {
    
                            $Body->add_text("".$i."");
                            $Body->add_text(" | ");
                        }else{
                        
                            $Body->add_link("".$link."&p=$i","".$i."",'normal');
                            $Body->add_text(" | ");
                        }
                    }
                
                    if(($p < $num_pages) && ($num_pages > 1))
                    {
                        $pg = $p + 1;
                        $Body->add_link("".$link."&p=$pg","»",'normal');
                    }else{
                        $Body->add_text("»");
                    }
                }
    }
blackhowk Senior · 411 posts #4

use this and edit.

<?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "$file\n"; } } closedir($handle); } ?>
wizard Senior · 493 posts #5
    function list_navigation($num_pages, $p, $link )
    {     
                if($num_pages > 1) {
                    $Body->do_br();
                    if($p > 1 )
                    {
                        $pg = $p - 1;
            echo '[url="'.$link.'&p='.$pg.'"]«[/url]';
            echo ' | ';

                    }else{
            echo '&#171';
            echo ' | ';
                    }
                
                    for ($i = 1; $i <= $num_pages; $i++)
                    {
                        if($p == $i)
                        {
    
            echo ''.$i.'';
            echo ' | ';
                        }else{
                        
            echo '[url="'.$link.'&p='.$i.'"]$i[/url]';
            echo ' | ';
                        }
                    }
                
                    if(($p < $num_pages) && ($num_pages > 1))
                    {
                        $pg = $p + 1;
            echo '[url="'.$link.'&p='.$pg.'"]»[/url]';
            echo ' | ';
                    }else{
                        echo ' » ';
                    }
                }
    }

made simpler than b4. it will give u a list like

 « | 1 | 2 | 3 | 4| 5 | »
Guest #6

Thanks for help, i do it self ;]

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close