I\'m trying to build a site that has a photo gallery and rather than build a database CMS I\'m trying it with the use of PHP and folders. At the moment I have a script to g
For paging you must calculate the total items to page , capture the parameter of the current page and iterate over the respective range.
0) ){
$page = $_GET["page"];
$offset = ($per_page + 1)*($page - 1);
}else{
echo "Page out of range showing results for page one";
$page=1;
$offset=0;
}
$max = $offset + $per_page;
if($max>$total){
$max = $total;
}
You can use the function pathinfo to get the file name without extension.
//print_r($files);
echo "Processsing page : $page offset: $offset max: $max total: $total last_page: $last_page";
show_pagination($page, $last_page);
for($i = $offset; $i< $max; $i++){
$file = $files[$i];
$path_parts = pathinfo($file);
$filename = $path_parts['filename'];
echo '
';
}
show_pagination($page, $last_page);
Using the following function you can create the navigation links
function show_pagination($current_page, $last_page){
echo '';
if( $current_page > 1 ){
echo ' <<Previous ';
}
if( $current_page < $last_page ){
echo ' Next>> ';
}
echo '';
}
?>