Sorry for the long and bad title,. In the script below Im using glob to output wave files from a directory called audio. Currently I output 3 rows from the directory. They are filename, size and date. The script works fine as is but I want to add code so I can sort the table column categories name, size and date both asc or desc by clicking on them. Any tips how I do this in a easy and simple way ?
<?php
$pageNo = $_GET['pageNo'];
$filesPerPage = "25";
$dir = "audio/*.wav";
$read = glob($dir);
$slice = array_slice($read,$pageNo,$filesPerPage);
echo "<table border='1'>";
echo "<tr><td colspan='3'><a href=./>Phonetic Database</a> [";
echo count($read)." files] ";
echo "<select onChange='location=this.options[this.selectedIndex].value;' size='1'>";
echo "<option>Select page</option>";
for($i=1; $i<=count($read)/$filesPerPage; $i++) {
echo "<option value=".$_SERVER['PHP_SELF']."?pageNo=$i>".$i."</option>";
}
echo "</select> [Page ".$pageNo."]</td></tr>";
$titles = array('name','size','date');
echo "<tr>";
foreach($titles as $title) {
echo "<td bgcolor='lightgrey'><a href='$title'>$title</a></td>";
}
echo "</tr>";
foreach ($slice as $filename) {
echo "<tr>";
echo "<td><a href='$filename'>".substr($filename,6)."</a></td>";
echo "<td> ".round(filesize($filename)/(1024)/(1024),1)." MB </td>";
echo "<td> ". date("d.m.Y H:i:s", filemtime($filename))." </td>";
echo "</tr>";
}
echo "</table>";
?>