mlowe.space12
New Member
- Messages
- 5
- Reaction score
- 0
- Points
- 1
in php how do you check if there are anymore files? i got the pagination to work but if the number of files is not a multiple of 4 then 1, 2 or 3 of the files will come up blank at the end because there are no files left. here is my code so far:
and if you want to see for your self: http://knexideas.x10.mx/ideas.php and click last
PHP:
<?php
if(!$_GET['start']) {
$start = 0;
} else {
$start = $_GET['start'];
}
$exclude_files = array("");
$ifiles = Array();
$handle = opendir('upload/');
$number_to_display = '4';
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && !in_array($file, $exclude_files)) {
$ifiles[] = $file;
}
}
closedir($handle);
$total_files = count($ifiles);
$req_pages = ceil($total_files/$number_to_display);
echo "Total Ideas = ". $total_files."<br><br>";
for($z=0; $z<$number_to_display; $z++) {
$vf = $z+$start;
$ifiles_display = explode(".", $ifiles[$vf]);
echo "<a href =upload/". $ifiles[$vf] . "> ";
echo "$ifiles[$vf]";
echo "</a>";
}
echo "<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>";
echo "<a href=\"?start=0\">First</a> |";
for($x=2; $x<$req_pages; $x++) { ?>
<a href="?start=<?php echo ($x-1)*$number_to_display; ?>"><?php echo ($x-1); ?></a> |
<?php } ?>
<a href="?start=<?php echo ($x-1)*$number_to_display; ?>">Last</a>
and if you want to see for your self: http://knexideas.x10.mx/ideas.php and click last
Last edited: