Hello.
There is something wrong with my pagination script below.
I have 7844 files in my audio folder wich Im listing out in the script below.
I'm viewing 25 files at a time, and have a dropdown menu to
paginate between all the pages (instead of next and previous
links). However the dropdown menu shows I have 7844 pages,
wich is wrong. 7844/25 = 313. So I should have 313 pages
showing in the dropdown menu and not 7844.
What am I doing wrong ?
<?php
$pageNo = $_GET['pageNo'];
$filesPerPage = "25";
$dir = "media/audio/*.wav";
$readDir = glob($dir);
$sliceDir = array_slice($readDir,$pageNo,$filesPerPage);
echo "<table border=1>";
echo "<tr><td bgcolor=gray colspan=3><font color=white>Phonetic Database<font></td><td bgcolor=gray><font color=white>".count($readDir)." files</font></td></tr>";
echo "<tr><td bgcolor=lightgrey>Name</td><td bgcolor=lightgrey>Size</td><td bgcolor=lightgrey>Date</td>";
echo "<td>Page ".$pageNo." ";
echo "<select onChange='location=this.options[this.selectedIndex].value;'>";
echo "<option>Select page</option>";
for($i=1; $i<=count($readDir); $i++) {
echo "<option value=".$_SERVER['PHP_SELF']."?pageNo=$i>".$i."</option>";
}
echo "</select></td>";
echo "</tr>";
foreach ($sliceDir as $file) {
echo "<tr>";
echo "<td><a href=# onclick=\"Popup=window.open('$file','Popup','location=no, width=200,height=20');\">".substr($file,26)."</a></td>";
echo "<td> ".round(filesize($file)/(1024)/(1024),1)." MB </td>";
echo "<td> ". date("d.m.Y H:i:s", filemtime($file))." </td>";
echo "</tr>";
}
echo "</table>";
?>