2015-07-11 42 views

回答

1

基於:pagination of php glob page

$folders = glob("*", GLOB_ONLYDIR); 
usort($folders, function ($a, $b) { 
return filemtime($b) - filemtime($a); 
}); 

$record_count = 20; 
$total_pages = ceil(count($folders)/$record_count); 
$page   = $_REQUEST['page']; ///make it dyanamic :: page num 
$offset  = ($page-1)*$record_count; 
$folders_filter = array_slice($folders, $offset,$record_count); 

foreach ($folders_filter as $folder) { 
echo "$folder <br/>"; 
} 

if($total_pages > 1){ 
    if($page != 1){ 
     echo '<a href="thispage.php?page='.($page-1).'">Prev</a>'; 
    } 
    if($page != $total_pages){ 
     echo '<a href="thispage.php?page='.($page+1).'">Next</a>'; 
    } 
} 
+0

感謝先生,這工作好 –

+0

歡迎您! –